Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Pryor <jpryor@novell.com>2004-12-28 22:54:39 +0300
committerJonathan Pryor <jpryor@novell.com>2004-12-28 22:54:39 +0300
commitc05ab5c33336c3cbb7783b1a48fb1176748bf7e4 (patch)
tree8530173b7734e6ee245ed94824a166b0cd8d9bd1 /mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs
parent03398ebee4c91fef05643933c96fdd1b2a57675b (diff)
* Mono.Posix.dll.sources: Add UnixDriveInfo and UnixPath.
* CdeclFunctions.cs: Correct the comments for AMD64 * UnixDirectoryInfo.cs: override Name; add Parent & Root properties; Correct Path usage (s/Path/FullPath/g). * UnixDriveInfo.cs: Added. Based on .NET 2.0 System.IO.DriveInfo docs, provides statvfs(2) and getfsfile(3) information about a mounted volume. GetDrives() wraps getfsent(3), thus parsing /etc/fstab. * UnixFile.cs: Use UnixConver.ToOpenFlags, deleting the local version. * UnixFileInfo.cs: Use UnixConver.ToOpenFlags, deleting the local version; override Name; add DirectoryName and Directory properties; * UnixFileSystemInfo.cs: Make more .NET-like, using FullPath and OriginalPath protected members, abstract Name property; Add CreateSymbolicLink; Remove ReadLink (it's now UnixSymbolicLinkInfo.Contents); Use lstat(2) for Create(string), so we properly detect Symbolic Links. * UnixPath.cs: Added; Path manipulation utility functions. * UnixSymbolicLinkInfo.cs: - Seal the class; - override new abstract member Name; - rename ReadLink to ContentsPath (and Contents) properties (why "Contents"? Because readlink(2) says "readlink places the contents of the symbolic link in the buffer...") - Add CreateSymbolicLinkTo(), which creates a symlink to the specified "normal" file svn path=/trunk/mcs/; revision=38140
Diffstat (limited to 'mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs')
-rw-r--r--mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs54
1 files changed, 3 insertions, 51 deletions
diff --git a/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs b/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs
index f2d65af295f..0b1fdee4cf4 100644
--- a/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs
+++ b/mcs/class/Mono.Posix/Mono.Unix/UnixFile.cs
@@ -173,7 +173,7 @@ namespace Mono.Unix {
public static UnixStream Open (string path, FileMode mode)
{
- OpenFlags flags = ToOpenFlags (mode, FileAccess.ReadWrite);
+ OpenFlags flags = UnixConvert.ToOpenFlags (mode, FileAccess.ReadWrite);
int fd = Syscall.open (path, flags);
if (fd < 0)
UnixMarshal.ThrowExceptionForLastError ();
@@ -182,7 +182,7 @@ namespace Mono.Unix {
public static UnixStream Open (string path, FileMode mode, FileAccess access)
{
- OpenFlags flags = ToOpenFlags (mode, access);
+ OpenFlags flags = UnixConvert.ToOpenFlags (mode, access);
int fd = Syscall.open (path, flags);
if (fd < 0)
UnixMarshal.ThrowExceptionForLastError ();
@@ -191,7 +191,7 @@ namespace Mono.Unix {
public static UnixStream Open (string path, FileMode mode, FileAccess access, FilePermissions perms)
{
- OpenFlags flags = ToOpenFlags (mode, access);
+ OpenFlags flags = UnixConvert.ToOpenFlags (mode, access);
int fd = Syscall.open (path, flags, perms);
if (fd < 0)
UnixMarshal.ThrowExceptionForLastError ();
@@ -256,54 +256,6 @@ namespace Mono.Unix {
SetLinkOwner (path, uid, gid);
}
- public static OpenFlags ToOpenFlags (FileMode mode, FileAccess access)
- {
- OpenFlags flags = 0;
- switch (mode) {
- case FileMode.CreateNew:
- flags = OpenFlags.O_CREAT | OpenFlags.O_EXCL;
- break;
- case FileMode.Create:
- flags = OpenFlags.O_CREAT | OpenFlags.O_TRUNC;
- break;
- case FileMode.Open:
- // do nothing
- break;
- case FileMode.OpenOrCreate:
- flags = OpenFlags.O_CREAT;
- break;
- case FileMode.Truncate:
- flags = OpenFlags.O_TRUNC;
- break;
- case FileMode.Append:
- flags = OpenFlags.O_APPEND;
- break;
- default:
- throw new ArgumentException (Locale.GetText ("Unsupported mode value"), "mode");
- }
-
- // Is O_LARGEFILE supported?
- int _v;
- if (UnixConvert.TryFromOpenFlags (OpenFlags.O_LARGEFILE, out _v))
- flags |= OpenFlags.O_LARGEFILE;
-
- switch (access) {
- case FileAccess.Read:
- flags |= OpenFlags.O_RDONLY;
- break;
- case FileAccess.Write:
- flags |= OpenFlags.O_WRONLY;
- break;
- case FileAccess.ReadWrite:
- flags |= OpenFlags.O_RDWR;
- break;
- default:
- throw new ArgumentException (Locale.GetText ("Unsupported access value"), "access");
- }
-
- return flags;
- }
-
public static void AdviseNormalAccess (int fd, long offset, long len)
{
int r = Syscall.posix_fadvise (fd, offset, len,