Fix problems with overlong directory names: phase #1
[mono.git] / mcs / class / Mono.Posix / Mono.Unix / UnixStream.cs
index 279a9dfb0640ee14b1473521eb806d6fc711347d..64795781531b8325ed254853ce3e1351b9599e31 100644 (file)
@@ -4,7 +4,7 @@
 // Authors:
 //   Jonathan Pryor (jonpryor@vt.edu)
 //
-// (C) 2004-2005 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
@@ -110,19 +110,6 @@ namespace Mono.Unix {
                        }
                }
 
-               [CLSCompliant (false)]
-               [Obsolete ("Use Protection", true)]
-               public FilePermissions Permissions {
-                       get {
-                               RefreshStat ();
-                               return (FilePermissions) stat.st_mode;
-                       }
-                       set {
-                               int r = Syscall.fchmod (fileDescriptor, value);
-                               UnixMarshal.ThrowExceptionForLastErrorIf (r);
-                       }
-               }
-
                [CLSCompliant (false)]
                public Native.FilePermissions Protection {
                        get {
@@ -140,7 +127,7 @@ namespace Mono.Unix {
                public FileTypes FileType {
                        get {
                                int type = (int) Protection;
-                               return (FileTypes) (type & (int) FileTypes.AllTypes);
+                               return (FileTypes) (type & (int) UnixFileSystemInfo.AllFileTypes);
                        }
                        // no set as fchmod(2) won't accept changing the file type.
                }
@@ -161,11 +148,11 @@ namespace Mono.Unix {
                public FileSpecialAttributes FileSpecialAttributes {
                        get {
                                int attrs = (int) Protection;
-                               return (FileSpecialAttributes) (attrs & (int) FileSpecialAttributes.AllAttributes);
+                               return (FileSpecialAttributes) (attrs & (int) UnixFileSystemInfo.AllSpecialAttributes);
                        }
                        set {
                                int perms = (int) Protection;
-                               perms &= (int) ~FileSpecialAttributes.AllAttributes;
+                               perms &= (int) ~UnixFileSystemInfo.AllSpecialAttributes;
                                perms |= (int) value;
                                Protection = (Native.FilePermissions) perms;
                        }
@@ -189,6 +176,7 @@ namespace Mono.Unix {
 
                private void RefreshStat ()
                {
+                       AssertNotDisposed ();
                        int r = Native.Syscall.fstat (fileDescriptor, out stat);
                        UnixMarshal.ThrowExceptionForLastErrorIf (r);
                }
@@ -203,98 +191,8 @@ namespace Mono.Unix {
                        AdviseFileAccessPattern (pattern, 0, 0);
                }
 
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.Normal, offset, len)", true)]
-               public void AdviseNormalAccess (long offset, long len)
-               {
-                       UnixFile.AdviseNormalAccess (fileDescriptor, offset, len);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.Normal)", true)]
-               public void AdviseNormalAccess ()
-               {
-                       UnixFile.AdviseNormalAccess (fileDescriptor);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.Sequential, offset, len)", true)]
-               public void AdviseSequentialAccess (long offset, long len)
-               {
-                       UnixFile.AdviseSequentialAccess (fileDescriptor, offset, len);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.Sequential)", true)]
-               public void AdviseSequentialAccess ()
-               {
-                       UnixFile.AdviseSequentialAccess (fileDescriptor);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.Random, offset, len)", true)]
-               public void AdviseRandomAccess (long offset, long len)
-               {
-                       UnixFile.AdviseRandomAccess (fileDescriptor, offset, len);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.Random)", true)]
-               public void AdviseRandomAccess ()
-               {
-                       UnixFile.AdviseRandomAccess (fileDescriptor);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.UseSoon, offset, len)", true)]
-               public void AdviseNeedAccess (long offset, long len)
-               {
-                       UnixFile.AdviseNeedAccess (fileDescriptor, offset, len);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.UseSoon)", true)]
-               public void AdviseNeedAccess ()
-               {
-                       UnixFile.AdviseNeedAccess (fileDescriptor);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.WillNotUse, offset, len)", true)]
-               public void AdviseNoAccess (long offset, long len)
-               {
-                       UnixFile.AdviseNoAccess (fileDescriptor, offset, len);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.WillNotUse)", true)]
-               public void AdviseNoAccess ()
-               {
-                       UnixFile.AdviseNoAccess (fileDescriptor);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.UseOnce, offset, len)", true)]
-               public void AdviseOnceAccess (long offset, long len)
-               {
-                       UnixFile.AdviseOnceAccess (fileDescriptor, offset, len);
-               }
-
-               [Obsolete ("Use AdviseFileAccessPattern (FileAccessPattern.UseOnce)", true)]
-               public void AdviseOnceAccess ()
-               {
-                       UnixFile.AdviseOnceAccess (fileDescriptor);
-               }
-
                public override void Flush ()
                {
-                       int r = Native.Syscall.fsync (fileDescriptor);
-
-                       if (r == -1) {
-                               Native.Errno e = Native.Stdlib.GetLastError ();
-
-                               // From the man page:
-                               //  EROFS, EINVAL:
-                               //    fd is bound to a special file which does not support
-                               //    synchronization.
-                               // Sockets are such a file, and since Close() calls Flush(), and we
-                               // want to support manually opened sockets, we shouldn't generate an
-                               // exception for these errors.
-                               if (e == Native.Errno.EROFS || e == Native.Errno.EINVAL) {
-                                       return;
-                               }
-
-                               UnixMarshal.ThrowExceptionForError (e);
-                       }
                }
 
                public override unsafe int Read ([In, Out] byte[] buffer, int offset, int count)
@@ -441,16 +339,6 @@ namespace Mono.Unix {
                                UnixMarshal.ThrowExceptionForLastError ();
                }
                
-               [CLSCompliant (false)]
-               [Obsolete ("Use SetOwner (long, long)", true)]
-               public void SetOwner (uint user, uint group)
-               {
-                       AssertNotDisposed ();
-
-                       int r = Native.Syscall.fchown (fileDescriptor, user, group);
-                       UnixMarshal.ThrowExceptionForLastErrorIf (r);
-               }
-
                public void SetOwner (long user, long group)
                {
                        AssertNotDisposed ();
@@ -481,17 +369,6 @@ namespace Mono.Unix {
                        SetOwner (uid, gid);
                }
 
-               [CLSCompliant (false)]
-               [Obsolete ("Use GetConfigurationValue (Mono.Unix.Native.PathconfName", true)]
-               public long GetConfigurationValue (PathConf name)
-               {
-                       AssertNotDisposed ();
-                       long r = Syscall.fpathconf (fileDescriptor, name);
-                       if (r == -1 && Syscall.GetLastError() != (Error) 0)
-                               UnixMarshal.ThrowExceptionForLastError ();
-                       return r;
-               }
-
                [CLSCompliant (false)]
                public long GetConfigurationValue (Native.PathconfName name)
                {
@@ -513,6 +390,10 @@ namespace Mono.Unix {
                                return;
                                
                        Flush ();
+
+                       if (!owner)
+                               return;
+
                        int r;
                        do {
                                r = Native.Syscall.close (fileDescriptor);