Mono.Unix/FileSpecialAttributes.cs, Mono.Unix/FileTypes.cs.
* Mono.Unix/FileAccessPermissions.cs, Mono.Unix/FileSpecialAttributes.cs,
Mono.Unix/FileTypes.cs: Added.
* Mono.Unix/UnixFileSystemInfo.cs, Mono.Unix/UnixStream.cs:
Replace the old Permission property
with 4 new properties: Protection (for the Native.FilePermissions value),
FileAccessPermissions (for rwxrwxrwx info), FileSpecialAttributes (for
set-user-id, set-group-id, sticky), and FileTypes (directory, socket...).
The new enumeration types have nicer CLS-compliant names.
svn path=/trunk/mcs/; revision=51928
+2005-10-19 Jonathan Pryor <jonpryor@vt.edu>
+
+ * Mono.Posix.dll.sources: Add new files: Mono.Unix/FileAccessPermissions.cs,
+ Mono.Unix/FileSpecialAttributes.cs, Mono.Unix/FileTypes.cs.
+
2005-10-17 Jonathan Pryor <jonpryor@vt.edu>
* Mono.Posix_test.dll.sources: Add Mono.Unix/UnixMarshalTest.cs.
../../build/common/Locale.cs
./Mono.Unix/Catalog.cs
./Mono.Unix/CdeclFunction.cs
+./Mono.Unix/FileAccessPermissions.cs
+./Mono.Unix/FileSpecialAttributes.cs
+./Mono.Unix/FileTypes.cs
./Mono.Unix/IncludeAttribute.cs
./Mono.Unix/MapAttribute.cs
./Mono.Unix/PeerCred.cs
+2005-10-19 Jonathan Pryor <jonpryor@vt.edu>
+
+ * FileAccessPermissions.cs, FileSpecialAttributes.cs, FileTypes.cs: Added.
+ * UnixFileSystemInfo.cs, UnixStream.cs: Replace the old Permission property
+ with 4 new properties: Protection (for the Native.FilePermissions value),
+ FileAccessPermissions (for rwxrwxrwx info), FileSpecialAttributes (for
+ set-user-id, set-group-id, sticky), and FileTypes (directory, socket...).
+ The new enumeration types have nicer CLS-compliant names.
+
2005-10-17 Jonathan Pryor <jonpryor@vt.edu>
* UnixMarshal.cs: Fix GetIntXxBufferLength to require fewer
--- /dev/null
+//
+// Mono.Unix/FileAccessPermissions.cs
+//
+// Authors:
+// Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2005 Jonathan Pryor
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Mono.Unix;
+
+namespace Mono.Unix {
+
+ [Flags]
+ public enum FileAccessPermissions {
+ UserReadWriteExecute = (int) Native.FilePermissions.S_IRWXU,
+ UserMask = UserReadWriteExecute,
+ UserRead = (int) Native.FilePermissions.S_IRUSR,
+ UserWrite = (int) Native.FilePermissions.S_IWUSR,
+ UserExecute = (int) Native.FilePermissions.S_IXUSR,
+ GroupReadWriteExecute = (int) Native.FilePermissions.S_IRWXG,
+ GroupMask = GroupReadWriteExecute,
+ GroupRead = (int) Native.FilePermissions.S_IRGRP,
+ GroupWrite = (int) Native.FilePermissions.S_IWGRP,
+ GroupExecute = (int) Native.FilePermissions.S_IXGRP,
+ OtherReadWriteExecute = (int) Native.FilePermissions.S_IRWXO,
+ OtherMask = OtherReadWriteExecute,
+ OtherRead = (int) Native.FilePermissions.S_IROTH,
+ OtherWrite = (int) Native.FilePermissions.S_IWOTH,
+ OtherExecute = (int) Native.FilePermissions.S_IXOTH,
+
+ DefaultPermissions = (int) Native.FilePermissions.DEFFILEMODE,
+ AllPermissions = (int) Native.FilePermissions.ACCESSPERMS,
+ }
+}
+
--- /dev/null
+//
+// Mono.Unix/FileSpecialAttributes.cs
+//
+// Authors:
+// Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2005 Jonathan Pryor
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Mono.Unix;
+
+namespace Mono.Unix {
+
+ [Flags]
+ public enum FileSpecialAttributes {
+ SetUserId = (int) Native.FilePermissions.S_ISUID,
+ SetGroupId = (int) Native.FilePermissions.S_ISGID,
+ Sticky = (int) Native.FilePermissions.S_ISVTX,
+ AllAttributes = SetUserId | SetGroupId | Sticky,
+ }
+}
+
--- /dev/null
+//
+// Mono.Unix/FileTypes.cs
+//
+// Authors:
+// Jonathan Pryor (jonpryor@vt.edu)
+//
+// (C) 2005 Jonathan Pryor
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using Mono.Unix;
+
+namespace Mono.Unix {
+
+ [Flags]
+ public enum FileTypes {
+ Directory = (int) Native.FilePermissions.S_IFDIR,
+ CharacterSpecial = (int) Native.FilePermissions.S_IFCHR,
+ BlockSpecial = (int) Native.FilePermissions.S_IFBLK,
+ RegularFile = (int) Native.FilePermissions.S_IFREG,
+ FIFO = (int) Native.FilePermissions.S_IFIFO,
+ SymbolicLink = (int) Native.FilePermissions.S_IFLNK,
+ Socket = (int) Native.FilePermissions.S_IFSOCK,
+ AllTypes =
+ Directory | CharacterSpecial | BlockSpecial | RegularFile | FIFO |
+ SymbolicLink | Socket,
+ }
+}
+
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
-// (C) 2004 Jonathan Pryor
+// (C) 2004-2005 Jonathan Pryor
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
}
[CLSCompliant (false)]
- [Obsolete ("The type of this property will change in the next release.")]
+ [Obsolete ("Use Protection.")]
public FilePermissions Mode {
get {AssertValid (); return stat.st_mode;}
}
[CLSCompliant (false)]
- [Obsolete ("The type of this property will change in the next release.")]
+ [Obsolete ("Use FileAccessPermissions.")]
public FilePermissions Permissions {
get {AssertValid (); return stat.st_mode & ~FilePermissions.S_IFMT;}
}
get {AssertValid (); return stat.st_mode & FilePermissions.S_IFMT;}
}
+ [CLSCompliant (false)]
+ public Native.FilePermissions Protection {
+ get {AssertValid (); return (Native.FilePermissions) stat.st_mode;}
+ set {
+ int r = Native.Syscall.chmod (FullPath, value);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ }
+ }
+
+#if false
+ public FileTypes FileType {
+ get {
+ AssertValid ();
+ int type = (int) stat.st_mode;
+ return (FileTypes) (type & (int) FileTypes.AllTypes);
+ }
+ // no set as chmod(2) won't accept changing the file type.
+ }
+#endif
+
+ public FileAccessPermissions FileAccessPermissions {
+ get {
+ AssertValid ();
+ int perms = (int) stat.st_mode;
+ return (FileAccessPermissions) (perms & (int) FileAccessPermissions.AllPermissions);
+ }
+ set {
+ AssertValid ();
+ int perms = (int) stat.st_mode;
+ perms &= (int) ~FileAccessPermissions.AllPermissions;
+ perms |= (int) value;
+ Protection = (Native.FilePermissions) perms;
+ }
+ }
+
+ public FileSpecialAttributes FileSpecialAttributes {
+ get {
+ AssertValid ();
+ int attrs = (int) stat.st_mode;
+ return (FileSpecialAttributes) (attrs & (int) FileSpecialAttributes.AllAttributes);
+ }
+ set {
+ AssertValid ();
+ int perms = (int) stat.st_mode;
+ perms &= (int) ~FileSpecialAttributes.AllAttributes;
+ perms |= (int) value;
+ Protection = (Native.FilePermissions) perms;
+ }
+ }
+
[CLSCompliant (false)]
[Obsolete ("The type of this property will change in the next release.")]
public ulong LinkCount {
}
[CLSCompliant (false)]
- [Obsolete ("Use SetPermissions (Mono.Unix.Native.FilePermissions)")]
+ [Obsolete ("Use Protection setter")]
public void SetPermissions (FilePermissions perms)
{
int r = Syscall.chmod (FullPath, perms);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- [CLSCompliant (false)]
- public void SetPermissions (Native.FilePermissions perms)
- {
- int r = Native.Syscall.chmod (FullPath, perms);
- UnixMarshal.ThrowExceptionForLastErrorIf (r);
- }
-
[CLSCompliant (false)]
[Obsolete ("Use SetOwner (long, long)")]
public virtual void SetOwner (uint owner, uint group)
// Authors:
// Jonathan Pryor (jonpryor@vt.edu)
//
-// (C) 2004 Jonathan Pryor
+// (C) 2004-2005 Jonathan Pryor
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
}
[CLSCompliant (false)]
- [Obsolete ("The type of this property will change in the next release.")]
+ [Obsolete ("Use Protection")]
public FilePermissions Permissions {
get {
Stat stat;
}
}
+ [CLSCompliant (false)]
+ public Native.FilePermissions Protection {
+ get {
+ Native.Stat stat;
+ int r = Native.Syscall.fstat (fileDescriptor, out stat);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ return stat.st_mode;
+ }
+ set {
+ // we can't change file type with fchmod, so clear out that portion
+ value &= ~Native.FilePermissions.S_IFMT;
+ int r = Native.Syscall.fchmod (fileDescriptor, value);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ }
+ }
+
+ public FileTypes FileType {
+ get {
+ int type = (int) Protection;
+ return (FileTypes) (type & (int) FileTypes.AllTypes);
+ }
+ // no set as fchmod(2) won't accept changing the file type.
+ }
+
+ public FileAccessPermissions FileAccessPermissions {
+ get {
+ int perms = (int) Protection;
+ return (FileAccessPermissions) (perms & (int) FileAccessPermissions.AllPermissions);
+ }
+ set {
+ int perms = (int) Protection;
+ perms &= (int) ~FileAccessPermissions.AllPermissions;
+ perms |= (int) value;
+ Protection = (Native.FilePermissions) perms;
+ }
+ }
+
+ public FileSpecialAttributes FileSpecialAttributes {
+ get {
+ int attrs = (int) Protection;
+ return (FileSpecialAttributes) (attrs & (int) FileSpecialAttributes.AllAttributes);
+ }
+ set {
+ int perms = (int) Protection;
+ perms &= (int) ~FileSpecialAttributes.AllAttributes;
+ perms |= (int) value;
+ Protection = (Native.FilePermissions) perms;
+ }
+ }
+
public void AdviseNormalAccess (long offset, long len)
{
UnixFile.AdviseNormalAccess (fileDescriptor, offset, len);