summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Bockover <abock@src.gnome.org>2005-10-27 15:41:12 +0000
committerAaron Bockover <abock@src.gnome.org>2005-10-27 15:41:12 +0000
commit948b5a5b1928eb0536894db101ed8d68dabe2d6f (patch)
treeffe8802fa267dbeaf4568bccc5e09e4fddaa663a
parent3b9937ea3848bc30e6ca30296eb442070d7f9c8b (diff)
Moved Mono.Unix.Native.NativeConvert code to local code for 1.1.8 compat.
-rw-r--r--src/Utilities.cs67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/Utilities.cs b/src/Utilities.cs
index bc047859c..e2a58206b 100644
--- a/src/Utilities.cs
+++ b/src/Utilities.cs
@@ -125,4 +125,71 @@ namespace Banshee
return String.Format(Catalog.GetString("{0} MB"), mb);
}
}
+
+ public class DateTimeUtil
+ {
+ public static readonly DateTime LocalUnixEpoch =
+ new DateTime(1970, 1, 1).ToLocalTime();
+
+ public static DateTime ToDateTime(long time)
+ {
+ return FromTimeT(time);
+ }
+
+ public static long FromDateTime(DateTime time)
+ {
+ return ToTimeT(time);
+ }
+
+ public static DateTime FromTimeT(long time)
+ {
+ return LocalUnixEpoch.AddSeconds(time);
+ }
+
+ public static long ToTimeT(DateTime time)
+ {
+ return (long)time.Subtract(LocalUnixEpoch).TotalSeconds;
+ }
+ }
+
+ public sealed class UnixFileUtil
+ {
+ [Flags]
+ public enum OpenFlags : int {
+ //
+ // One of these
+ //
+ O_RDONLY = 0x00000000,
+ O_WRONLY = 0x00000001,
+ O_RDWR = 0x00000002,
+
+ //
+ // Or-ed with zero or more of these
+ //
+ O_CREAT = 0x00000040,
+ O_EXCL = 0x00000080,
+ O_NOCTTY = 0x00000100,
+ O_TRUNC = 0x00000200,
+ O_APPEND = 0x00000400,
+ O_NONBLOCK = 0x00000800,
+ O_SYNC = 0x00001000,
+
+ //
+ // These are non-Posix. Using them will result in errors/exceptions on
+ // non-supported platforms.
+ //
+ // (For example, "C-wrapped" system calls -- calls with implementation in
+ // MonoPosixHelper -- will return -1 with errno=EINVAL. C#-wrapped system
+ // calls will generate an exception in NativeConvert, as the value can't be
+ // converted on the target platform.)
+ //
+
+ O_NOFOLLOW = 0x00020000,
+ O_DIRECTORY = 0x00010000,
+ O_DIRECT = 0x00004000,
+ O_ASYNC = 0x00002000,
+ O_LARGEFILE = 0x00008000
+ }
+ }
}
+