Author: jonpryor
Date: 2005-11-01 10:25:10 -0500 (Tue, 01 Nov 2005)
New Revision: 52444
Added:
trunk/mcs/class/Mono.Posix/Mono.Unix/FileHandleOperations.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixPipes.cs
Modified:
trunk/mcs/class/Mono.Posix/ChangeLog
trunk/mcs/class/Mono.Posix/Mono.Posix.dll.sources
trunk/mcs/class/Mono.Posix/Mono.Unix/ChangeLog
trunk/mcs/class/Mono.Posix/Mono.Unix/FileAccessPattern.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectory.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectoryInfo.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFileSystemInfo.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroup.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroupInfo.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixStream.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixSymbolicLinkInfo.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUser.cs
trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUserInfo.cs
Log:
* Mono.Posix.dll.sources: Add new files: Mono.Unix/FileHandleOperations.cs,
Mono.Unix/UnixPipes.cs.
* Mono.Unix/FileAccessPattern.cs: Change enumeration names to match
Robert Love's more sensible names from his FileAdvise class used in Beagle
(UseSoon --> PreLoad, WillNotUse --> FlushCache).
* Mono.Unix/FileHandleOperations.cs: Added; contains AdviseFileAccessPattern()
(moved from UnixFile.cs).
* Mono.Unix/UnixDirectory.cs: Obsolete the class; use UnixDirectoryInfo
instead.
* Mono.Unix/UnixDirectoryInfo.cs: Add GetCurrentDirectory(),
SetCurrentDirectory().
* Mono.Unix/UnixFile.cs: Obsolete the class; use UnixFileInfo,
FileHandleOperations, or UnixPipes instead.
* Mono.Unix/UnixFileSystemInfo.cs: Add ToStat() method.
* Mono.Unix/UnixGroup.cs: Obsolete the class; use UnixGroupInfo instead.
* Mono.Unix/UnixGroupInfo.cs: Obsolete & Replace constructor, add
GetMemberNames(), GetLocalGroups().
* Mono.Unix/UnixPipes.cs: Added (type moved from UnixFile.cs).
* Mono.Unix/UnixStream.cs: AdviseFileAccessPattern() uses
FileHandleOperations now.
* Mono.Unix/UnixSymbolicLinkInfo.cs: Implement TryReadLink() to avoid
constant
buffer re-sizing. Stevens states that the file size of the symlink is the
number of bytes needed to hold the symlink, so this should be faster.
* Mono.Unix/UnixUser.cs: Obsolete the class; use UnixUserInfo instead.
* Mono.Unix/UnixUserInfo.cs: Obsolete & Replace constructor; add useful
static members from UnixUser such as GetLoginName(), GetLocalUsers(), etc.
Modified: trunk/mcs/class/Mono.Posix/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Posix/ChangeLog 2005-11-01 15:20:04 UTC (rev
52443)
+++ trunk/mcs/class/Mono.Posix/ChangeLog 2005-11-01 15:25:10 UTC (rev
52444)
@@ -1,3 +1,8 @@
+2005-11-01 Jonathan Pryor <[EMAIL PROTECTED]>
+
+ * Mono.Posix.dll.sources: Add new files:
Mono.Unix/FileHandleOperations.cs,
+ Mono.Unix/UnixPipes.cs.
+
2005-10-25 Jonathan Pryor <[EMAIL PROTECTED]>
* Mono.Posix.dll.sources: Add Mono.Unix.Native/FileNameMarshaler.cs.
Modified: trunk/mcs/class/Mono.Posix/Mono.Posix.dll.sources
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Posix.dll.sources 2005-11-01 15:20:04 UTC
(rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Posix.dll.sources 2005-11-01 15:25:10 UTC
(rev 52444)
@@ -5,6 +5,7 @@
./Mono.Unix/CdeclFunction.cs
./Mono.Unix/FileAccessPermissions.cs
./Mono.Unix/FileAccessPattern.cs
+./Mono.Unix/FileHandleOperations.cs
./Mono.Unix/FileSpecialAttributes.cs
./Mono.Unix/FileTypes.cs
./Mono.Unix/IncludeAttribute.cs
@@ -30,6 +31,7 @@
./Mono.Unix/UnixListener.cs
./Mono.Unix/UnixMarshal.cs
./Mono.Unix/UnixPath.cs
+./Mono.Unix/UnixPipes.cs
./Mono.Unix/UnixProcess.cs
./Mono.Unix/UnixStream.cs
./Mono.Unix/UnixSymbolicLinkInfo.cs
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/ChangeLog
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/ChangeLog 2005-11-01 15:20:04 UTC
(rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/ChangeLog 2005-11-01 15:25:10 UTC
(rev 52444)
@@ -1,3 +1,27 @@
+2005-11-01 Jonathan Pryor <[EMAIL PROTECTED]>
+
+ * FileAccessPattern.cs: Change enumeration names to match Robert Love's
more
+ sensible names from his FileAdvise class used in Beagle
+ (UseSoon --> PreLoad, WillNotUse --> FlushCache).
+ * FileHandleOperations.cs: Added; contains AdviseFileAccessPattern()
+ (moved from UnixFile.cs).
+ * UnixDirectory.cs: Obsolete the class; use UnixDirectoryInfo instead.
+ * UnixDirectoryInfo.cs: Add GetCurrentDirectory(),
SetCurrentDirectory().
+ * UnixFile.cs: Obsolete the class; use UnixFileInfo,
FileHandleOperations,
+ or UnixPipes instead.
+ * UnixFileSystemInfo.cs: Add ToStat() method.
+ * UnixGroup.cs: Obsolete the class; use UnixGroupInfo instead.
+ * UnixGroupInfo.cs: Obsolete & Replace constructor, add
GetMemberNames(),
+ GetLocalGroups().
+ * UnixPipes.cs: Added (type moved from UnixFile.cs).
+ * UnixStream.cs: AdviseFileAccessPattern() uses FileHandleOperations
now.
+ * UnixSymbolicLinkInfo.cs: Implement TryReadLink() to avoid constant
buffer
+ re-sizing. Stevens states that the file size of the symlink is the
number
+ of bytes needed to hold the symlink, so this should be faster.
+ * UnixUser.cs: Obsolete the class; use UnixUserInfo instead.
+ * UnixUserInfo.cs: Obsolete & Replace constructor; add useful static
members
+ from UnixUser such as GetLoginName(), GetLocalUsers(), etc.
+
2005-10-27 Jonathan Pryor <[EMAIL PROTECTED]>
* UnixEnvironment.cs: Add RealUser, RealGroup, EffectiveUser,
EffectiveGroup
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/FileAccessPattern.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/FileAccessPattern.cs 2005-11-01
15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/FileAccessPattern.cs 2005-11-01
15:25:10 UTC (rev 52444)
@@ -35,9 +35,9 @@
Normal = Native.PosixFadviseAdvice.POSIX_FADV_NORMAL,
Sequential = Native.PosixFadviseAdvice.POSIX_FADV_SEQUENTIAL,
Random = Native.PosixFadviseAdvice.POSIX_FADV_RANDOM,
- UseOnce = Native.PosixFadviseAdvice.POSIX_FADV_NOREUSE,
- UseSoon = Native.PosixFadviseAdvice.POSIX_FADV_WILLNEED,
- WillNotUse = Native.PosixFadviseAdvice.POSIX_FADV_DONTNEED,
+ NoReuse = Native.PosixFadviseAdvice.POSIX_FADV_NOREUSE,
+ PreLoad = Native.PosixFadviseAdvice.POSIX_FADV_WILLNEED,
+ FlushCache = Native.PosixFadviseAdvice.POSIX_FADV_DONTNEED,
}
}
Added: trunk/mcs/class/Mono.Posix/Mono.Unix/FileHandleOperations.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/FileHandleOperations.cs
2005-11-01 15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/FileHandleOperations.cs
2005-11-01 15:25:10 UTC (rev 52444)
@@ -0,0 +1,78 @@
+//
+// Mono.Unix/FileHandleOperations.cs
+//
+// Authors:
+// Jonathan Pryor ([EMAIL PROTECTED])
+//
+// (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 System.IO;
+using System.Text;
+using Mono.Unix;
+
+namespace Mono.Unix {
+
+ public sealed /* static */ class FileHandleOperations
+ {
+ private FileHandleOperations () {}
+
+ public static void AdviseFileAccessPattern (int fd,
FileAccessPattern pattern, long offset, long len)
+ {
+ int r = Syscall.posix_fadvise (fd, offset, len,
+ (PosixFadviseAdvice) pattern);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ }
+
+ public static void AdviseFileAccessPattern (int fd,
FileAccessPattern pattern)
+ {
+ AdviseFileAccessPattern (fd, pattern, 0, 0);
+ }
+
+ public static void AdviseFileAccessPattern (FileStream file,
FileAccessPattern pattern, long offset, long len)
+ {
+ int r = Syscall.posix_fadvise (file.Handle.ToInt32(),
offset, len,
+ (PosixFadviseAdvice) pattern);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ }
+
+ public static void AdviseFileAccessPattern (FileStream file,
FileAccessPattern pattern)
+ {
+ AdviseFileAccessPattern (file, pattern, 0, 0);
+ }
+
+ public static void AdviseFileAccessPattern (UnixStream stream,
FileAccessPattern pattern, long offset, long len)
+ {
+ int r = Syscall.posix_fadvise (stream.Handle, offset,
len,
+ (PosixFadviseAdvice) pattern);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ }
+
+ public static void AdviseFileAccessPattern (UnixStream stream,
FileAccessPattern pattern)
+ {
+ AdviseFileAccessPattern (stream, pattern, 0, 0);
+ }
+ }
+}
+
+// vim: noexpandtab
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectory.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectory.cs 2005-11-01
15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectory.cs 2005-11-01
15:25:10 UTC (rev 52444)
@@ -4,7 +4,7 @@
// Authors:
// Jonathan Pryor ([EMAIL PROTECTED])
//
-// (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
@@ -35,12 +35,13 @@
namespace Mono.Unix {
+ [Obsolete ("Use UnixDirectoryInfo")]
public sealed class UnixDirectory
{
private UnixDirectory () {}
[CLSCompliant (false)]
- [Obsolete ("Use CreateDirectory (string,
Mono.Unix.Native.FilePermissions)")]
+ [Obsolete ("Use new UnixDirectoryInfo(path).Create (mode)")]
public static UnixDirectoryInfo CreateDirectory (string path,
FilePermissions mode)
{
int r = Syscall.mkdir (path, mode);
@@ -48,30 +49,26 @@
return new UnixDirectoryInfo (path);
}
- [CLSCompliant (false)]
- public static UnixDirectoryInfo CreateDirectory (string path,
Native.FilePermissions mode)
- {
- int r = Native.Syscall.mkdir (path, mode);
- UnixMarshal.ThrowExceptionForLastErrorIf (r);
- return new UnixDirectoryInfo (path);
- }
-
+ [Obsolete ("Use new UnixDirectoryInfo(path).Create ()")]
public static UnixDirectoryInfo CreateDirectory (string path)
{
FilePermissions mode = FilePermissions.ACCESSPERMS;
return CreateDirectory (path, mode);
}
+ [Obsolete ("Use new UnixDirectoryInfo(path).Delete ()")]
public static void Delete (string path)
{
Delete (path, false);
}
+ [Obsolete ("Use new UnixDirectoryInfo(path).Delete
(recursive)")]
public static void Delete (string path, bool recursive)
{
new UnixDirectoryInfo (path).Delete (recursive);
}
+ [Obsolete ("Use new UnixDirectoryInfo(path).Exists")]
public static bool Exists (string path)
{
int r = Syscall.access (path, AccessMode.F_OK);
@@ -80,45 +77,49 @@
return false;
}
- [Obsolete ("The return type of this method will change in the
next release")]
+ [Obsolete ("Use new UnixDirectoryInfo(path).GetEntries()")]
public static Dirent[] GetEntries (string path)
{
return new UnixDirectoryInfo(path).GetEntries ();
}
- [Obsolete ("The return type of this method will change in the
next release")]
+ [Obsolete ("Use new UnixDirectoryInfo(path).GetEntries(regex)")]
public static Dirent[] GetEntries (string path, Regex regex)
{
return new UnixDirectoryInfo(path).GetEntries (regex);
}
- [Obsolete ("The return type of this method will change in the
next release")]
+ [Obsolete ("Use new UnixDirectoryInfo(path).GetEntries(regex)")]
public static Dirent[] GetEntries (string path, string regex)
{
return new UnixDirectoryInfo(path).GetEntries (regex);
}
+ [Obsolete ("Use new
UnixDirectoryInfo(path).GetFileSystemEntries()")]
public static UnixFileSystemInfo[] GetFileSystemEntries (string
path)
{
return new UnixDirectoryInfo(path).GetFileSystemEntries
();
}
+ [Obsolete ("Use new
UnixDirectoryInfo(path).GetFileSystemEntries(regex)")]
public static UnixFileSystemInfo[] GetFileSystemEntries (string
path, Regex regex)
{
return new UnixDirectoryInfo(path).GetFileSystemEntries
(regex);
}
+ [Obsolete ("Use new
UnixDirectoryInfo(path).GetFileSystemEntries(regex)")]
public static UnixFileSystemInfo[] GetFileSystemEntries (string
path, string regex)
{
return new UnixDirectoryInfo(path).GetFileSystemEntries
(regex);
}
- [Obsolete ("The return type of this method will change in the
next release")]
+ [Obsolete ("Use new UnixDirectoryInfo(path).ToStat()")]
public static Stat GetDirectoryStatus (string path)
{
return UnixFile.GetFileStatus (path);
}
+ [Obsolete ("Use new UnixDirectoryInfo.GetCurrentDirectory()")]
public static string GetCurrentDirectory ()
{
StringBuilder buf = new StringBuilder (16);
@@ -132,6 +133,7 @@
return buf.ToString ();
}
+ [Obsolete ("Use new
UnixDirectoryInfo.SetCurrentDirectory(path)")]
public static void SetCurrentDirectory (string path)
{
int r = Syscall.chdir (path);
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectoryInfo.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectoryInfo.cs 2005-11-01
15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixDirectoryInfo.cs 2005-11-01
15:25:10 UTC (rev 52444)
@@ -229,6 +229,25 @@
Regex re = new Regex (regex);
return GetFileSystemEntries (re);
}
+
+ public static string GetCurrentDirectory ()
+ {
+ StringBuilder buf = new StringBuilder (16);
+ IntPtr r = IntPtr.Zero;
+ do {
+ buf.Capacity *= 2;
+ r = Syscall.getcwd (buf, (ulong) buf.Capacity);
+ } while (r == IntPtr.Zero && Syscall.GetLastError() ==
Error.ERANGE);
+ if (r == IntPtr.Zero)
+ UnixMarshal.ThrowExceptionForLastError ();
+ return buf.ToString ();
+ }
+
+ public static void SetCurrentDirectory (string path)
+ {
+ int r = Syscall.chdir (path);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ }
}
}
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs 2005-11-01 15:20:04 UTC
(rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs 2005-11-01 15:25:10 UTC
(rev 52444)
@@ -33,24 +33,13 @@
namespace Mono.Unix {
- public struct UnixPipes
- {
- public UnixPipes (UnixStream reading, UnixStream writing)
- {
- Reading = reading;
- Writing = writing;
- }
-
- public UnixStream Reading;
- public UnixStream Writing;
- }
-
+ [Obsolete ("Use UnixFileInfo or FileHandleOperations")]
public sealed /* static */ class UnixFile
{
private UnixFile () {}
[CLSCompliant (false)]
- [Obsolete ("Use CanAccess(string,
Mono.Unix.Native.AccessModes)")]
+ [Obsolete ("Use new UnixFileInfo(path).CanAccess (mode)")]
public static bool CanAccess (string path, AccessMode mode)
{
int r = Syscall.access (path, mode);
@@ -58,18 +47,21 @@
}
[CLSCompliant (false)]
+ [Obsolete ("Use new UnixFileInfo(path).CanAccess (mode)")]
public static bool CanAccess (string path, Native.AccessModes
mode)
{
int r = Native.Syscall.access (path, mode);
return r == 0;
}
+ [Obsolete ("Use new UnixFileInfo(path).Delete()")]
public static void Delete (string path)
{
int r = Syscall.unlink (path);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
+ [Obsolete ("Use new UnixFileInfo(path).Exists")]
public static bool Exists (string path)
{
int r = Syscall.access (path, AccessMode.F_OK);
@@ -79,7 +71,7 @@
}
[CLSCompliant (false)]
- [Obsolete ("Use GetConfigurationValue(string,
Mono.Unix.Native.PathconfName)")]
+ [Obsolete ("Use new
UnixFileInfo(path).GetConfigurationValue(name)")]
public static long GetConfigurationValue (string path, PathConf
name)
{
long r = Syscall.pathconf (path, name);
@@ -89,6 +81,7 @@
}
[CLSCompliant (false)]
+ [Obsolete ("Use new
UnixFileInfo(path).GetConfigurationValue(name)")]
public static long GetConfigurationValue (string path,
Native.PathconfName name)
{
long r = Native.Syscall.pathconf (path, name,
(Native.Errno) 0);
@@ -97,12 +90,13 @@
return r;
}
+ [Obsolete ("Use new UnixFileInfo(path).LastAccessTime")]
public static DateTime GetLastAccessTime (string path)
{
return new UnixFileInfo (path).LastAccessTime;
}
- [Obsolete ("The return type of this method will change in the
next release")]
+ [Obsolete ("Use new UnixFileInfo(path).ToStat()")]
public static Stat GetFileStatus (string path)
{
Stat stat;
@@ -111,23 +105,26 @@
return stat;
}
+ [Obsolete ("Use new UnixFileInfo(path).LastWriteTime")]
public static DateTime GetLastWriteTime (string path)
{
return new UnixFileInfo(path).LastWriteTime;
}
+ [Obsolete ("Use new UnixFileInfo(path).LastStatusChangeTime")]
public static DateTime GetLastStatusChangeTime (string path)
{
return new UnixFileInfo (path).LastStatusChangeTime;
}
[CLSCompliant (false)]
- [Obsolete ("Return Type will change in next release")]
+ [Obsolete ("Use new UnixFileInfo(path).Protection")]
public static FilePermissions GetPermissions (string path)
{
return new UnixFileInfo (path).Permissions;
}
+ [Obsolete ("Use new UnixSymbolicLinkInfo(path).ContentsPath")]
public static string ReadLink (string path)
{
string r = TryReadLink (path);
@@ -136,6 +133,7 @@
return r;
}
+ [Obsolete ("Use new UnixSymbolicLinkInfo(path).TryReadLink")]
public static string TryReadLink (string path)
{
// Who came up with readlink(2)? There doesn't seem to
be a way to
@@ -148,7 +146,7 @@
}
[CLSCompliant (false)]
- [Obsolete("Use SetPermissions(string,
Mono.Unix.Native.FilePermissions)")]
+ [Obsolete ("Use new UnixFileInfo(path).Protection = perms")]
public static void SetPermissions (string path, FilePermissions
perms)
{
int r = Syscall.chmod (path, perms);
@@ -156,12 +154,14 @@
}
[CLSCompliant (false)]
+ [Obsolete ("Use new UnixFileInfo(path).Protection = perms")]
public static void SetPermissions (string path,
Native.FilePermissions perms)
{
int r = Native.Syscall.chmod (path, perms);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
+ [Obsolete ("Use new UnixFileInfo(path).Create ()")]
public static UnixStream Create (string path)
{
FilePermissions mode = // 0644
@@ -171,7 +171,7 @@
}
[CLSCompliant (false)]
- [Obsolete ("Use Create(string,
Mono.Unix.Native.FilePermissions)")]
+ [Obsolete ("Use new UnixFileInfo(path).Create (mode)")]
public static UnixStream Create (string path, FilePermissions
mode)
{
int fd = Syscall.creat (path, mode);
@@ -181,6 +181,7 @@
}
[CLSCompliant (false)]
+ [Obsolete ("Use new UnixFileInfo(path).Create (mode)")]
public static UnixStream Create (string path,
Native.FilePermissions mode)
{
int fd = Native.Syscall.creat (path, mode);
@@ -189,6 +190,7 @@
return new UnixStream (fd);
}
+ [Obsolete ("Use UnixPipes.CreatePipes()")]
public static UnixPipes CreatePipes ()
{
int reading, writing;
@@ -198,7 +200,7 @@
}
[CLSCompliant (false)]
- [Obsolete ("Use Open(string, Mono.Unix.Native.OpenFlags)")]
+ [Obsolete ("Use new UnixFileInfo(path).Open (flags)")]
public static UnixStream Open (string path, OpenFlags flags)
{
int fd = Syscall.open (path, flags);
@@ -208,6 +210,7 @@
}
[CLSCompliant (false)]
+ [Obsolete ("Use new UnixFileInfo(path).Open (flags)")]
public static UnixStream Open (string path, Native.OpenFlags
flags)
{
int fd = Native.Syscall.open (path, flags);
@@ -217,7 +220,7 @@
}
[CLSCompliant (false)]
- [Obsolete ("Use Open(string, Mono.Unix.Native.OpenFlags,
Mono.Unix.Native.FilePermissions)")]
+ [Obsolete ("Use new UnixFileInfo(path).Open (flags, mode)")]
public static UnixStream Open (string path, OpenFlags flags,
FilePermissions mode)
{
int fd = Syscall.open (path, flags, mode);
@@ -227,6 +230,7 @@
}
[CLSCompliant (false)]
+ [Obsolete ("Use new UnixFileInfo(path).Open (flags, mode)")]
public static UnixStream Open (string path, Native.OpenFlags
flags, Native.FilePermissions mode)
{
int fd = Native.Syscall.open (path, flags, mode);
@@ -235,6 +239,7 @@
return new UnixStream (fd);
}
+ [Obsolete ("Use new UnixFileInfo(path).Open (mode)")]
public static UnixStream Open (string path, FileMode mode)
{
OpenFlags flags = UnixConvert.ToOpenFlags (mode,
FileAccess.ReadWrite);
@@ -244,6 +249,7 @@
return new UnixStream (fd);
}
+ [Obsolete ("Use new UnixFileInfo(path).Open (mode, access)")]
public static UnixStream Open (string path, FileMode mode,
FileAccess access)
{
OpenFlags flags = UnixConvert.ToOpenFlags (mode,
access);
@@ -254,7 +260,7 @@
}
[CLSCompliant (false)]
- [Obsolete ("Use Open(string, FileMode, FileAccess,
Mono.Unix.Native.FilePermissions)")]
+ [Obsolete ("Use new UnixFileInfo(path).Open (mode, access,
perms)")]
public static UnixStream Open (string path, FileMode mode,
FileAccess access, FilePermissions perms)
{
OpenFlags flags = UnixConvert.ToOpenFlags (mode,
access);
@@ -265,6 +271,7 @@
}
[CLSCompliant (false)]
+ [Obsolete ("Use new UnixFileInfo(path).Open (mode, access,
perms)")]
public static UnixStream Open (string path, FileMode mode,
FileAccess access, Native.FilePermissions perms)
{
Native.OpenFlags flags =
Native.NativeConvert.ToOpenFlags (mode, access);
@@ -274,32 +281,27 @@
return new UnixStream (fd);
}
+ [Obsolete ("Use new UnixFileInfo(path).OpenRead ()")]
public static UnixStream OpenRead (string path)
{
return Open (path, FileMode.Open, FileAccess.Read);
}
+ [Obsolete ("Use new UnixFileInfo(path).OpenWrite ()")]
public static UnixStream OpenWrite (string path)
{
return Open (path, FileMode.OpenOrCreate,
FileAccess.Write);
}
[CLSCompliant (false)]
- [Obsolete ("Use SetOwner (string, long, long)")]
+ [Obsolete ("Use new UnixFileInfo(path).SetOwner (owner,
group)")]
public static void SetOwner (string path, uint owner, uint
group)
{
int r = Syscall.chown (path, owner, group);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- public static void SetOwner (string path, long owner, long
group)
- {
- uint _owner = Convert.ToUInt32 (owner);
- uint _group = Convert.ToUInt32 (group);
- int r = Syscall.chown (path, _owner, _group);
- UnixMarshal.ThrowExceptionForLastErrorIf (r);
- }
-
+ [Obsolete ("Use new UnixFileInfo(path).SetOwner (owner)")]
public static void SetOwner (string path, string owner)
{
Passwd pw = Syscall.getpwnam (owner);
@@ -310,6 +312,7 @@
SetOwner (path, uid, gid);
}
+ [Obsolete ("Use new UnixFileInfo(path).SetOwner (owner,
group)")]
public static void SetOwner (string path, string owner, string
group)
{
uint uid = UnixUser.GetUserId (owner);
@@ -319,21 +322,14 @@
}
[CLSCompliant (false)]
- [Obsolete ("Use SetLinkOwner (string, long, long)")]
+ [Obsolete ("Use new UnixSymbolicLinkInfo(path).SetOwner (owner,
group)")]
public static void SetLinkOwner (string path, uint owner, uint
group)
{
int r = Syscall.lchown (path, owner, group);
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- public static void SetLinkOwner (string path, long owner, long
group)
- {
- uint _owner = Convert.ToUInt32 (owner);
- uint _group = Convert.ToUInt32 (group);
- int r = Syscall.lchown (path, _owner, _group);
- UnixMarshal.ThrowExceptionForLastErrorIf (r);
- }
-
+ [Obsolete ("Use new UnixSymbolicLinkInfo(path).SetOwner
(owner)")]
public static void SetLinkOwner (string path, string owner)
{
Passwd pw = Syscall.getpwnam (owner);
@@ -344,6 +340,7 @@
SetLinkOwner (path, uid, gid);
}
+ [Obsolete ("Use new UnixSymbolicLinkInfo(path).SetOwner (owner,
group)")]
public static void SetLinkOwner (string path, string owner,
string group)
{
uint uid = UnixUser.GetUserId (owner);
@@ -352,43 +349,7 @@
SetLinkOwner (path, uid, gid);
}
- public static void AdviseFileAccessPattern (int fd,
FileAccessPattern pattern, long offset, long len)
- {
- int r = Syscall.posix_fadvise (fd, offset, len,
- (PosixFadviseAdvice) pattern);
- UnixMarshal.ThrowExceptionForLastErrorIf (r);
- }
-
- public static void AdviseFileAccessPattern (int fd,
FileAccessPattern pattern)
- {
- AdviseFileAccessPattern (fd, pattern, 0, 0);
- }
-
- public static void AdviseFileAccessPattern (FileStream file,
FileAccessPattern pattern, long offset, long len)
- {
- int r = Syscall.posix_fadvise (file.Handle.ToInt32(),
offset, len,
- (PosixFadviseAdvice) pattern);
- UnixMarshal.ThrowExceptionForLastErrorIf (r);
- }
-
- public static void AdviseFileAccessPattern (FileStream file,
FileAccessPattern pattern)
- {
- AdviseFileAccessPattern (file, pattern, 0, 0);
- }
-
- public static void AdviseFileAccessPattern (UnixStream stream,
FileAccessPattern pattern, long offset, long len)
- {
- int r = Syscall.posix_fadvise (stream.Handle, offset,
len,
- (PosixFadviseAdvice) pattern);
- UnixMarshal.ThrowExceptionForLastErrorIf (r);
- }
-
- public static void AdviseFileAccessPattern (UnixStream stream,
FileAccessPattern pattern)
- {
- AdviseFileAccessPattern (stream, pattern, 0, 0);
- }
-
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.Normal, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.Normal, offset, len)")]
public static void AdviseNormalAccess (int fd, long offset,
long len)
{
int r = Syscall.posix_fadvise (fd, offset, len,
@@ -396,37 +357,37 @@
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.Normal)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.Normal)")]
public static void AdviseNormalAccess (int fd)
{
AdviseNormalAccess (fd, 0, 0);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.Normal, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.Normal, offset, len)")]
public static void AdviseNormalAccess (FileStream file, long
offset, long len)
{
AdviseNormalAccess (file.Handle.ToInt32(), offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.Normal)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.Normal)")]
public static void AdviseNormalAccess (FileStream file)
{
AdviseNormalAccess (file.Handle.ToInt32());
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.Normal, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.Normal, offset, len)")]
public static void AdviseNormalAccess (UnixStream stream, long
offset, long len)
{
AdviseNormalAccess (stream.Handle, offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.Normal)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.Normal)")]
public static void AdviseNormalAccess (UnixStream stream)
{
AdviseNormalAccess (stream.Handle);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.Sequential, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.Sequential, offset, len)")]
public static void AdviseSequentialAccess (int fd, long offset,
long len)
{
int r = Syscall.posix_fadvise (fd, offset, len,
@@ -434,37 +395,37 @@
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.Sequential)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.Sequential)")]
public static void AdviseSequentialAccess (int fd)
{
AdviseSequentialAccess (fd, 0, 0);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.Sequential, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.Sequential, offset, len)")]
public static void AdviseSequentialAccess (FileStream file,
long offset, long len)
{
AdviseSequentialAccess (file.Handle.ToInt32(), offset,
len);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.Sequential)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.Sequential)")]
public static void AdviseSequentialAccess (FileStream file)
{
AdviseSequentialAccess (file.Handle.ToInt32());
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.Sequential, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.Sequential, offset, len)")]
public static void AdviseSequentialAccess (UnixStream stream,
long offset, long len)
{
AdviseSequentialAccess (stream.Handle, offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.Sequential)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.Sequential)")]
public static void AdviseSequentialAccess (UnixStream stream)
{
AdviseSequentialAccess (stream.Handle);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.Random, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.Random, offset, len)")]
public static void AdviseRandomAccess (int fd, long offset,
long len)
{
int r = Syscall.posix_fadvise (fd, offset, len,
@@ -472,37 +433,37 @@
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.Random)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.Random)")]
public static void AdviseRandomAccess (int fd)
{
AdviseRandomAccess (fd, 0, 0);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.Random, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.Random, offset, len)")]
public static void AdviseRandomAccess (FileStream file, long
offset, long len)
{
AdviseRandomAccess (file.Handle.ToInt32(), offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.Random)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.Random)")]
public static void AdviseRandomAccess (FileStream file)
{
AdviseRandomAccess (file.Handle.ToInt32());
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.Random, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.Random, offset, len)")]
public static void AdviseRandomAccess (UnixStream stream, long
offset, long len)
{
AdviseRandomAccess (stream.Handle, offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.Random)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.Random)")]
public static void AdviseRandomAccess (UnixStream stream)
{
AdviseRandomAccess (stream.Handle);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.UseSoon, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.PreLoad, offset, len)")]
public static void AdviseNeedAccess (int fd, long offset, long
len)
{
int r = Syscall.posix_fadvise (fd, offset, len,
@@ -510,37 +471,37 @@
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.UseSoon)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.PreLoad)")]
public static void AdviseNeedAccess (int fd)
{
AdviseNeedAccess (fd, 0, 0);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.UseSoon, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.PreLoad, offset, len)")]
public static void AdviseNeedAccess (FileStream file, long
offset, long len)
{
AdviseNeedAccess (file.Handle.ToInt32(), offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.UseSoon)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.PreLoad)")]
public static void AdviseNeedAccess (FileStream file)
{
AdviseNeedAccess (file.Handle.ToInt32());
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.UseSoon, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.PreLoad, offset, len)")]
public static void AdviseNeedAccess (UnixStream stream, long
offset, long len)
{
AdviseNeedAccess (stream.Handle, offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.UseSoon)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.PreLoad)")]
public static void AdviseNeedAccess (UnixStream stream)
{
AdviseNeedAccess (stream.Handle);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.WillNotUse, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.FlushCache, offset, len)")]
public static void AdviseNoAccess (int fd, long offset, long
len)
{
int r = Syscall.posix_fadvise (fd, offset, len,
@@ -548,37 +509,37 @@
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.WillNotUse)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.FlushCache)")]
public static void AdviseNoAccess (int fd)
{
AdviseNoAccess (fd, 0, 0);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.WillNotUse, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.FlushCache, offset, len)")]
public static void AdviseNoAccess (FileStream file, long
offset, long len)
{
AdviseNoAccess (file.Handle.ToInt32(), offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.WillNotUse)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.FlushCache)")]
public static void AdviseNoAccess (FileStream file)
{
AdviseNoAccess (file.Handle.ToInt32());
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.WillNotUse, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.FlushCache, offset, len)")]
public static void AdviseNoAccess (UnixStream stream, long
offset, long len)
{
AdviseNoAccess (stream.Handle, offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.WillNotUse)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.FlushCache)")]
public static void AdviseNoAccess (UnixStream stream)
{
AdviseNoAccess (stream.Handle);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.UseOnce, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.NoReuse, offset, len)")]
public static void AdviseOnceAccess (int fd, long offset, long
len)
{
int r = Syscall.posix_fadvise (fd, offset, len,
@@ -586,31 +547,31 @@
UnixMarshal.ThrowExceptionForLastErrorIf (r);
}
- [Obsolete ("Use AdviseFileAccessPattern (fd,
FileAccessPattern.UseOnce)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(fd, FileAccessPattern.NoReuse)")]
public static void AdviseOnceAccess (int fd)
{
AdviseOnceAccess (fd, 0, 0);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.UseOnce, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.NoReuse, offset, len)")]
public static void AdviseOnceAccess (FileStream file, long
offset, long len)
{
AdviseOnceAccess (file.Handle.ToInt32(), offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (file,
FileAccessPattern.UseOnce)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(file, FileAccessPattern.NoReuse)")]
public static void AdviseOnceAccess (FileStream file)
{
AdviseOnceAccess (file.Handle.ToInt32());
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.UseOnce, offset, len)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.NoReuse, offset, len)")]
public static void AdviseOnceAccess (UnixStream stream, long
offset, long len)
{
AdviseOnceAccess (stream.Handle, offset, len);
}
- [Obsolete ("Use AdviseFileAccessPattern (stream,
FileAccessPattern.UseOnce)")]
+ [Obsolete ("Use FileHandleOperations.AdviseFileAccessPattern
(stream, FileAccessPattern.NoReuse)")]
public static void AdviseOnceAccess (UnixStream stream)
{
AdviseOnceAccess (stream.Handle);
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFileSystemInfo.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFileSystemInfo.cs 2005-11-01
15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixFileSystemInfo.cs 2005-11-01
15:25:10 UTC (rev 52444)
@@ -423,6 +423,25 @@
return FullPath;
}
+ public Native.Stat ToStat ()
+ {
+ Native.Stat stat = new Native.Stat ();
+ stat.st_dev = this.stat.st_dev;
+ stat.st_ino = this.stat.st_ino;
+ stat.st_mode = (Native.FilePermissions)
this.stat.st_mode;
+ stat.st_nlink = this.stat.st_nlink;
+ stat.st_uid = this.stat.st_uid;
+ stat.st_gid = this.stat.st_gid;
+ stat.st_rdev = this.stat.st_rdev;
+ stat.st_size = this.stat.st_size;
+ stat.st_blksize = this.stat.st_blksize;
+ stat.st_blocks = this.stat.st_blocks;
+ stat.st_atime = this.stat.st_atime;
+ stat.st_mtime = this.stat.st_mtime;
+ stat.st_ctime = this.stat.st_ctime;
+ return stat;
+ }
+
internal static UnixFileSystemInfo Create (string path)
{
Stat stat;
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroup.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroup.cs 2005-11-01 15:20:04 UTC
(rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroup.cs 2005-11-01 15:25:10 UTC
(rev 52444)
@@ -4,7 +4,7 @@
// Authors:
// Jonathan Pryor ([EMAIL PROTECTED])
//
-// (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
@@ -32,70 +32,77 @@
namespace Mono.Unix {
+ [Obsolete ("Use UnixGroupInfo")]
public sealed class UnixGroup
{
private UnixGroup () {}
[CLSCompliant (false)]
- [Obsolete ("The return type will change in the next release")]
+ [Obsolete ("Use new UnixGroupInfo(group).GroupId")]
public static uint GetGroupId (string group)
{
return new UnixGroupInfo (group).GroupId;
}
+ [Obsolete ("Use new UnixGroupInfo(group).GetMemberNames")]
public static string[] GetMembers (string group)
{
return new UnixGroupInfo (group).Members;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetMembers (long)")]
+ [Obsolete ("Use new UnixGroupInfo(group).GetMemberNames")]
public static string[] GetMembers (uint group)
{
return new UnixGroupInfo (group).Members;
}
+ [Obsolete ("Use new UnixGroupInfo(group).GetMemberNames")]
public static string[] GetMembers (long group)
{
return new UnixGroupInfo (group).GetMembers ();
}
[CLSCompliant (false)]
- [Obsolete ("Use GetGroupName (long)")]
+ [Obsolete ("Use new UnixGroupInfo(group).GroupName")]
public static string GetName (uint group)
{
return new UnixGroupInfo (group).GroupName;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetGroupName(long)")]
+ [Obsolete ("Use new UnixGroupInfo(group).GroupName")]
public static string GetGroupName (uint group)
{
return new UnixGroupInfo (group).GroupName;
}
+ [Obsolete ("Use new UnixGroupInfo(group).GroupName")]
public static string GetGroupName (long group)
{
return new UnixGroupInfo (group).GroupName;
}
+ [Obsolete ("Use new UnixGroupInfo(group).Password")]
public static string GetPassword (string group)
{
return new UnixGroupInfo (group).Password;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetPassword(long)")]
+ [Obsolete ("Use new UnixGroupInfo(group).Password")]
public static string GetPassword (uint group)
{
return new UnixGroupInfo (group).Password;
}
+ [Obsolete ("Use new UnixGroupInfo(group).Password")]
public static string GetPassword (long group)
{
return new UnixGroupInfo (group).Password;
}
+ [Obsolete ("Use UnixGroupInfo.GetLocalGroups")]
public static UnixGroupInfo[] GetLocalGroups ()
{
ArrayList entries = new ArrayList ();
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroupInfo.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroupInfo.cs 2005-11-01
15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixGroupInfo.cs 2005-11-01
15:25:10 UTC (rev 52444)
@@ -4,7 +4,7 @@
// Authors:
// Jonathan Pryor ([EMAIL PROTECTED])
//
-// (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
@@ -27,6 +27,7 @@
//
using System;
+using System.Collections;
using System.Text;
using Mono.Unix;
@@ -65,11 +66,21 @@
throw new ArgumentException (Locale.GetText
("invalid group id"), "group");
}
+ [Obsolete ("Use UnixGroupInfo(Mono.Unix.Native.Group)")]
public UnixGroupInfo (Group group)
{
this.group = group;
}
+ public UnixGroupInfo (Native.Group group)
+ {
+ this.group = new Group ();
+ this.group.gr_name = group.gr_name;
+ this.group.gr_passwd = group.gr_passwd;
+ this.group.gr_gid = group.gr_gid;
+ this.group.gr_mem = group.gr_mem;
+ }
+
public string GroupName {
get {return group.gr_name;}
}
@@ -84,16 +95,22 @@
get {return group.gr_gid;}
}
- [Obsolete ("Use GetMembers()")]
+ [Obsolete ("Use GetMemberNames()")]
public string[] Members {
get {return group.gr_mem;}
}
+ [Obsolete ("The return type will change to UnixUserInfo[] in
the next release")]
public string[] GetMembers ()
{
return group.gr_mem;
}
+ public string[] GetMemberNames ()
+ {
+ return group.gr_mem;
+ }
+
public override int GetHashCode ()
{
return group.GetHashCode ();
@@ -116,6 +133,26 @@
{
return group;
}
+
+ public static UnixGroupInfo[] GetLocalGroups ()
+ {
+ ArrayList entries = new ArrayList ();
+ lock (Syscall.grp_lock) {
+ if (Native.Syscall.setgrent () != 0)
+ UnixMarshal.ThrowExceptionForLastError
();
+ try {
+ Group g;
+ while ((g = Syscall.getgrent()) != null)
+ entries.Add (new UnixGroupInfo
(g));
+ if (Syscall.GetLastError() != (Error) 0)
+
UnixMarshal.ThrowExceptionForLastError ();
+ }
+ finally {
+ Native.Syscall.endgrent ();
+ }
+ }
+ return (UnixGroupInfo[]) entries.ToArray
(typeof(UnixGroupInfo));
+ }
}
}
Added: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixPipes.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixPipes.cs 2005-11-01 15:20:04 UTC
(rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixPipes.cs 2005-11-01 15:25:10 UTC
(rev 52444)
@@ -0,0 +1,57 @@
+//
+// Mono.Unix/UnixPipes.cs
+//
+// Authors:
+// Jonathan Pryor ([EMAIL PROTECTED])
+//
+// (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
+// "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 System.IO;
+using System.Text;
+using Mono.Unix;
+
+namespace Mono.Unix {
+
+ public struct UnixPipes
+ {
+ public UnixPipes (UnixStream reading, UnixStream writing)
+ {
+ Reading = reading;
+ Writing = writing;
+ }
+
+ public UnixStream Reading;
+ public UnixStream Writing;
+
+ public static UnixPipes CreatePipes ()
+ {
+ int reading, writing;
+ int r = Syscall.pipe (out reading, out writing);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ return new UnixPipes (new UnixStream (reading), new
UnixStream (writing));
+ }
+ }
+}
+
+// vim: noexpandtab
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixStream.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixStream.cs 2005-11-01 15:20:04 UTC
(rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixStream.cs 2005-11-01 15:25:10 UTC
(rev 52444)
@@ -195,7 +195,7 @@
public void AdviseFileAccessPattern (FileAccessPattern pattern,
long offset, long len)
{
- UnixFile.AdviseFileAccessPattern (fileDescriptor,
pattern, offset, len);
+ FileHandleOperations.AdviseFileAccessPattern
(fileDescriptor, pattern, offset, len);
}
public void AdviseFileAccessPattern (FileAccessPattern pattern)
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixSymbolicLinkInfo.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixSymbolicLinkInfo.cs
2005-11-01 15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixSymbolicLinkInfo.cs
2005-11-01 15:25:10 UTC (rev 52444)
@@ -118,7 +118,11 @@
private string TryReadLink ()
{
- return UnixPath.ReadSymbolicLink (FullPath);
+ StringBuilder sb = new StringBuilder ((int)
base.Length+1);
+ int r = Syscall.readlink (FullPath, sb);
+ if (r == -1)
+ return null;
+ return sb.ToString (0, r);
}
}
}
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUser.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUser.cs 2005-11-01 15:20:04 UTC
(rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUser.cs 2005-11-01 15:25:10 UTC
(rev 52444)
@@ -4,7 +4,7 @@
// Authors:
// Jonathan Pryor ([EMAIL PROTECTED])
//
-// (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
@@ -33,29 +33,32 @@
namespace Mono.Unix {
+ [Obsolete ("Use UnixUserInfo")]
public sealed class UnixUser
{
private UnixUser () {}
[CLSCompliant (false)]
- [Obsolete ("The return type of this method will change after
the next release")]
+ [Obsolete ("Use new UnixUserInfo(user).UserId")]
public static uint GetUserId (string user)
{
return new UnixUserInfo (user).UserId;
}
[CLSCompliant (false)]
- [Obsolete ("The return type of this method will change after
the next release")]
+ [Obsolete ("Use UnixUserInfo.GetRealUserId()")]
public static uint GetCurrentUserId ()
{
return Syscall.getuid ();
}
+ [Obsolete ("Use UnixUserInfo.GetRealUser().UserName")]
public static string GetCurrentUserName ()
{
return GetName (GetCurrentUserId ());
}
+ [Obsolete ("Use UnixUserInfo.GetRealUser()")]
public static UnixUserInfo GetCurrentUser ()
{
return new UnixUserInfo (GetCurrentUserId ());
@@ -63,6 +66,7 @@
// I would hope that this is the same as GetCurrentUserName,
but it is a
// different syscall, so who knows.
+ [Obsolete ("Use UnixUserInfo.GetLoginName()")]
public static string GetLogin ()
{
StringBuilder buf = new StringBuilder (4);
@@ -76,105 +80,86 @@
}
[CLSCompliant (false)]
- [Obsolete ("The return type of this method will change after
the next release")]
+ [Obsolete ("Use new UnixUserInfo(user).GroupId")]
public static uint GetGroupId (string user)
{
return new UnixUserInfo (user).GroupId;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetGroupId (long)")]
+ [Obsolete ("Use new UnixUserInfo(user).GroupId")]
public static uint GetGroupId (uint user)
{
return new UnixUserInfo (user).GroupId;
}
- public static long GetGroupId (long user)
- {
- return new UnixUserInfo (user).GroupId;
- }
-
+ [Obsolete ("Use new UnixUserInfo(user).RealName")]
public static string GetRealName (string user)
{
return new UnixUserInfo (user).RealName;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetRealName (long)")]
+ [Obsolete ("Use new UnixUserInfo(user).RealName")]
public static string GetRealName (uint user)
{
return new UnixUserInfo (user).RealName;
}
- public static string GetRealName (long user)
- {
- return new UnixUserInfo (user).RealName;
- }
-
+ [Obsolete ("Use new UnixUserInfo(user).HomeDirectory")]
public static string GetHomeDirectory (string user)
{
return new UnixUserInfo (user).HomeDirectory;
}
[CLSCompliant (false)]
+ [Obsolete ("Use new UnixUserInfo(user).HomeDirectory")]
public static string GetHomeDirectory (uint user)
{
return new UnixUserInfo (user).HomeDirectory;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetUserName(long)")]
+ [Obsolete ("Use new UnixUserInfo(user).UserName")]
public static string GetName (uint user)
{
return new UnixUserInfo (user).UserName;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetUserName(long)")]
+ [Obsolete ("Use new UnixUserInfo(user).UserName")]
public static string GetUserName (uint user)
{
return new UnixUserInfo (user).UserName;
}
- public static string GetUserName (long user)
- {
- return new UnixUserInfo (user).UserName;
- }
-
+ [Obsolete ("Use new UnixUserInfo(user).Password")]
public static string GetPassword (string user)
{
return new UnixUserInfo (user).Password;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetPassword (long)")]
+ [Obsolete ("Use new UnixUserInfo(user).Password")]
public static string GetPassword (uint user)
{
return new UnixUserInfo (user).Password;
}
- public static string GetPassword (long user)
- {
- return new UnixUserInfo (user).Password;
- }
-
+ [Obsolete ("Use new UnixUserInfo(user).ShellProgram")]
public static string GetShellProgram (string user)
{
return new UnixUserInfo (user).ShellProgram;
}
[CLSCompliant (false)]
- [Obsolete ("Use GetShellProgram(long)")]
+ [Obsolete ("Use new UnixUserInfo(user).ShellProgram")]
public static string GetShellProgram (uint user)
{
return new UnixUserInfo (user).ShellProgram;
}
- public static string GetShellProgram (long user)
- {
- return new UnixUserInfo (user).ShellProgram;
- }
-
+ [Obsolete ("Use UnixUserInfo.GetLocalUsers")]
public static UnixUserInfo[] GetLocalUsers ()
{
ArrayList entries = new ArrayList ();
Modified: trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUserInfo.cs
===================================================================
--- trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUserInfo.cs 2005-11-01
15:20:04 UTC (rev 52443)
+++ trunk/mcs/class/Mono.Posix/Mono.Unix/UnixUserInfo.cs 2005-11-01
15:25:10 UTC (rev 52444)
@@ -4,7 +4,7 @@
// Authors:
// Jonathan Pryor ([EMAIL PROTECTED])
//
-// (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
@@ -47,7 +47,6 @@
}
[CLSCompliant (false)]
- [Obsolete ("Use UnixUserInfo (long)")]
public UnixUserInfo (uint user)
{
passwd = new Passwd ();
@@ -66,11 +65,24 @@
throw new ArgumentException (Locale.GetText
("invalid user id"), "user");
}
+ [Obsolete ("Use UnixUserInfo (Mono.Unix.Native.Passwd)")]
public UnixUserInfo (Passwd passwd)
{
this.passwd = passwd;
}
+ public UnixUserInfo (Native.Passwd passwd)
+ {
+ this.passwd = new Passwd ();
+ this.passwd.pw_name = passwd.pw_name;
+ this.passwd.pw_passwd = passwd.pw_passwd;
+ this.passwd.pw_uid = passwd.pw_uid;
+ this.passwd.pw_gid = passwd.pw_gid;
+ this.passwd.pw_gecos = passwd.pw_gecos;
+ this.passwd.pw_dir = passwd.pw_dir;
+ this.passwd.pw_shell = passwd.pw_shell;
+ }
+
public string UserName {
get {return passwd.pw_name;}
}
@@ -85,6 +97,10 @@
get {return passwd.pw_uid;}
}
+ public UnixGroupInfo Group {
+ get {return new UnixGroupInfo (passwd.pw_gid);}
+ }
+
[CLSCompliant (false)]
[Obsolete ("The type of this property will change in the next
release")]
public uint GroupId {
@@ -124,11 +140,56 @@
return passwd.ToString ();
}
+ public static UnixUserInfo GetRealUser ()
+ {
+ return new UnixUserInfo (GetRealUserId ());
+ }
+
+ public static long GetRealUserId ()
+ {
+ return Syscall.getuid ();
+ }
+
+ // I would hope that this is the same as GetCurrentUserName,
but it is a
+ // different syscall, so who knows.
+ public static string GetLoginName ()
+ {
+ StringBuilder buf = new StringBuilder (4);
+ int r;
+ do {
+ buf.Capacity *= 2;
+ r = Syscall.getlogin_r (buf, (ulong)
buf.Capacity);
+ } while (r == (-1) && Syscall.GetLastError() ==
Error.ERANGE);
+ UnixMarshal.ThrowExceptionForLastErrorIf (r);
+ return buf.ToString ();
+ }
+
[Obsolete ("The return type of this method will change in the
next release")]
public Passwd ToPasswd ()
{
return passwd;
}
+
+ public static UnixUserInfo[] GetLocalUsers ()
+ {
+ ArrayList entries = new ArrayList ();
+ lock (Syscall.pwd_lock) {
+ if (Native.Syscall.setpwent () != 0) {
+ UnixMarshal.ThrowExceptionForLastError
();
+ }
+ try {
+ Passwd p;
+ while ((p = Syscall.getpwent()) != null)
+ entries.Add (new UnixUserInfo
(p));
+ if (Syscall.GetLastError () != (Error)
0)
+
UnixMarshal.ThrowExceptionForLastError ();
+ }
+ finally {
+ Syscall.endpwent ();
+ }
+ }
+ return (UnixUserInfo[]) entries.ToArray
(typeof(UnixUserInfo));
+ }
}
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches