// 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
}
}
- [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 {
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.
}
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;
}
private void RefreshStat ()
{
+ AssertNotDisposed ();
int r = Native.Syscall.fstat (fileDescriptor, out stat);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
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)
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 ();
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)
{
return;
Flush ();
+
+ if (!owner)
+ return;
+
int r;
do {
r = Native.Syscall.close (fileDescriptor);