Fix problems with overlong directory names: phase #1
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / UnixFileInfo.cs
index 3c00c64af75ec0c020e3b1716bcc43f6331ee962..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
@@ -72,17 +72,6 @@ namespace Mono.Unix {
                        return Create (mode);
                }
 
-               [CLSCompliant (false)]
-               [Obsolete ("Use Create(Mono.Unix.Native.FilePermissions)", true)]
-               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)", true)]
-               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)", true)]
-               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)
                {
@@ -134,30 +113,13 @@ namespace Mono.Unix {
                public UnixStream Open (FileMode mode)
                {
                        Native.OpenFlags flags = Native.NativeConvert.ToOpenFlags (mode, FileAccess.ReadWrite);
-                       int fd = Native.Syscall.open (FullPath, flags);
-                       if (fd < 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       return new UnixStream (fd);
+                       return Open (flags);
                }
 
                public UnixStream Open (FileMode mode, FileAccess access)
                {
                        Native.OpenFlags flags = Native.NativeConvert.ToOpenFlags (mode, access);
-                       int fd = Native.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)", true)]
-               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);
+                       return Open (flags);
                }
 
                [CLSCompliant (false)]