Merge pull request #717 from mono/client_websockets_impl
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / UnixFileInfo.cs
index a883b75f66fa797561ed7385bf87ed41503ae693..48248c14312bd2d4cde1204e0a1d45450039af80 100644 (file)
@@ -4,7 +4,7 @@
 // Authors:
 //   Jonathan Pryor (jonpryor@vt.edu)
 //
-// (C) 2004 Jonathan Pryor
+// (C) 2004-2006 Jonathan Pryor
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -59,30 +59,19 @@ namespace Mono.Unix {
 
                public override void Delete ()
                {
-                       int r = Syscall.unlink (FullPath);
+                       int r = Native.Syscall.unlink (FullPath);
                        UnixMarshal.ThrowExceptionForLastErrorIf (r);
                        base.Refresh ();
                }
 
                public UnixStream Create ()
                {
-                       FilePermissions mode = // 0644
-                               FilePermissions.S_IRUSR | FilePermissions.S_IWUSR |
-                               FilePermissions.S_IRGRP | FilePermissions.S_IROTH; 
+                       Native.FilePermissions mode = // 0644
+                               Native.FilePermissions.S_IRUSR | Native.FilePermissions.S_IWUSR |
+                               Native.FilePermissions.S_IRGRP | Native.FilePermissions.S_IROTH; 
                        return Create (mode);
                }
 
-               [CLSCompliant (false)]
-               [Obsolete ("Use Create(Mono.Unix.Native.FilePermissions)")]
-               public UnixStream Create (FilePermissions mode)
-               {
-                       int fd = Syscall.creat (FullPath, mode);
-                       if (fd < 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       base.Refresh ();
-                       return new UnixStream (fd);
-               }
-
                [CLSCompliant (false)]
                public UnixStream Create (Native.FilePermissions mode)
                {
@@ -93,35 +82,25 @@ namespace Mono.Unix {
                        return new UnixStream (fd);
                }
 
-               [CLSCompliant (false)]
-               [Obsolete ("Use Open(Mono.Unix.Native.OpenFlags)")]
-               public UnixStream Open (OpenFlags flags)
+               public UnixStream Create (FileAccessPermissions mode)
                {
-                       int fd = Syscall.open (FullPath, flags);
-                       if (fd < 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       return new UnixStream (fd);
+                       return Create ((Native.FilePermissions) mode);
                }
 
                [CLSCompliant (false)]
                public UnixStream Open (Native.OpenFlags flags)
                {
+                       if ((flags & Native.OpenFlags.O_CREAT) != 0)
+                               throw new ArgumentException (
+                                               "Cannot specify OpenFlags.O_CREAT without providing " + 
+                                               "FilePermissions.  Use the Open(OpenFlags, FilePermissions) " +
+                                               "method instead");
                        int fd = Native.Syscall.open (FullPath, flags);
                        if (fd < 0)
                                UnixMarshal.ThrowExceptionForLastError ();
                        return new UnixStream (fd);
                }
 
-               [CLSCompliant (false)]
-               [Obsolete ("Use Open(Mono.Unix.Native.OpenFlags,Mono.Unix.Native.FilePermissions)")]
-               public UnixStream Open (OpenFlags flags, FilePermissions mode)
-               {
-                       int fd = Syscall.open (FullPath, flags, mode);
-                       if (fd < 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       return new UnixStream (fd);
-               }
-
                [CLSCompliant (false)]
                public UnixStream Open (Native.OpenFlags flags, Native.FilePermissions mode)
                {
@@ -133,31 +112,14 @@ namespace Mono.Unix {
 
                public UnixStream Open (FileMode mode)
                {
-                       OpenFlags flags = UnixConvert.ToOpenFlags (mode, FileAccess.ReadWrite);
-                       int fd = Syscall.open (FullPath, flags);
-                       if (fd < 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       return new UnixStream (fd);
+                       Native.OpenFlags flags = Native.NativeConvert.ToOpenFlags (mode, FileAccess.ReadWrite);
+                       return Open (flags);
                }
 
                public UnixStream Open (FileMode mode, FileAccess access)
                {
-                       OpenFlags flags = UnixConvert.ToOpenFlags (mode, access);
-                       int fd = Syscall.open (FullPath, flags);
-                       if (fd < 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       return new UnixStream (fd);
-               }
-
-               [CLSCompliant (false)]
-               [Obsolete ("Use Open (System.IO.FileMode,System.IO.FileAccess,Mono.Unix.Native.FilePermissions)")]
-               public UnixStream Open (FileMode mode, FileAccess access, FilePermissions perms)
-               {
-                       OpenFlags flags = UnixConvert.ToOpenFlags (mode, access);
-                       int fd = Syscall.open (FullPath, flags, perms);
-                       if (fd < 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       return new UnixStream (fd);
+                       Native.OpenFlags flags = Native.NativeConvert.ToOpenFlags (mode, access);
+                       return Open (flags);
                }
 
                [CLSCompliant (false)]