-/*---------------------------------------------------------------------\r
-\r
- XX X XXX\r
- XX XX\r
- XXX XX XXX XXXXX XX\r
- XX XXX XX XX XX\r
- XX XX XX XX XXXXX XX\r
- XX XX XX XX XX XX X XX\r
- XXXX XX XX XXX XXXXXXX XXXX\r
- XX\r
- XXXXX\r
-\r
-Copyright (c) 2001 Intel Corporation. All Rights Reserved.\r
-\r
-CREATED: August 22, 2001\r
-OWNER: Scott D Smith, Joel Marcey\r
-VERSION: 1.0\r
----------------------------------------------------------------------*/\r
- \r
-using System;\r
-using System.Runtime.InteropServices;\r
-using System.Text;\r
-using System.IO;\r
-using System.Collections;\r
+/*---------------------------------------------------------------------
+
+ XX X XXX
+ XX XX
+ XXX XX XXX XXXXX XX
+ XX XXX XX XX XX
+ XX XX XX XX XXXXX XX
+ XX XX XX XX XX XX X XX
+ XXXX XX XX XXX XXXXXXX XXXX
+ XX
+ XXXXX
+
+Copyright (c) 2001 Intel Corporation. All Rights Reserved.
+
+CREATED: August 22, 2001
+OWNER: Scott D Smith, Joel Marcey
+VERSION: 1.0
+---------------------------------------------------------------------*/
+
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.IO;
+using System.Collections;
using System.Reflection;
-\r
-namespace System.PAL\r
-{\r
- /// <summary>\r
- /// Class that implements IOperatingSystem, providing the requested functionality through calls into APIs available in Linux \r
- /// </summary>\r
+using System.Runtime.CompilerServices;
+
+namespace System.PAL
+{
+ /// <summary>
+ /// Class that implements IOperatingSystem, providing the requested functionality through calls into APIs available in Linux
+ /// </summary>
internal class OpSys
- {\r
- private Hashtable _environment = null;\r
-\r
- //----------------------------------\r
- // Class Constants\r
- //----------------------------------\r
- private const int EOF = -1; // TODO: Linux: Is this true?\r
- \r
-\r
- // For StdInputStream and StdOutputStream\r
- private const int STDOUT = 1; // TODO: Linux: Is this true?\r
- private const int STDIN = 0; // TODO: Linux: Is this true?\r
-\r
-\r
- //----------------------------------\r
- // Class Fields\r
- //----------------------------------\r
-\r
- //----------------------------------\r
- // Class Constructor\r
- //----------------------------------\r
- public OpSys()\r
- {\r
- }\r
-\r
-\r
- //-------------------------------------------------\r
- // Environment Services \r
- //-------------------------------------------------\r
-\r
- public string NewLineSequence\r
- {\r
- get\r
- {\r
- return "\n";\r
- }\r
- }\r
-\r
- public char DirectorySeparator\r
- {\r
- get\r
- {\r
- return '/';\r
- }\r
- }\r
-\r
- public char AltDirectorySeparator\r
- {\r
- get\r
- {\r
- return '\\';\r
- }\r
- }\r
-\r
- public char VolumeSeparator\r
- {\r
- get\r
- {\r
- return '/';\r
- }\r
- }\r
-\r
- public char PathSeparator\r
- {\r
- get\r
- {\r
- return ':';\r
- }\r
- }\r
-\r
- public char[] InvalidPathChars\r
- {\r
- get\r
- {\r
- return new char[] { '\0' };\r
- }\r
- }\r
-\r
- public char[] DirVolSeparatorChars\r
- {\r
- get\r
- {\r
- return new char[] { this.DirectorySeparator, this.AltDirectorySeparator, this.VolumeSeparator};\r
- }\r
- }\r
- public char ExtensionCharacter\r
- {\r
- get\r
- {\r
- return '.';\r
- }\r
- }\r
-\r
- public string GetEnvironmentVariable(string eVar)\r
- {\r
- return EnvironmentVariables[eVar].ToString();\r
- }\r
-\r
- public IDictionary EnvironmentVariables\r
- {\r
- get\r
- {\r
- if (_environment == null) {\r
- IntPtr pp = _getEnviron(); // pointer to an array of char*\r
- _environment = new Hashtable();\r
- \r
- if (pp != IntPtr.Zero) {\r
- IntPtr p;\r
- bool done = false;\r
- char[] delimiter = { '=' };\r
- \r
- while (!done) \r
- {\r
- p = Marshal.ReadIntPtr(pp);\r
- if (p != IntPtr.Zero) \r
- {\r
- string str = Marshal.PtrToStringAuto(p);\r
- string[] ar = str.Split(delimiter, 2);\r
- switch(ar.Length) \r
- {\r
- case 1:\r
- _environment.Add(ar[0], "");\r
- break;\r
- case 2:\r
- _environment.Add(ar[0], ar[1]);\r
- break;\r
- default:\r
- System.Diagnostics.Debug.Assert(false); // this shouldn't happen\r
- break;\r
- }\r
- } \r
- else \r
- {\r
- done = true;\r
- }\r
- }\r
- } \r
- } \r
- return _environment;\r
- }\r
- }\r
-\r
- public string CommandLine\r
- {\r
- get\r
- {\r
- string path = Path.Combine(Path.Combine("/proc", _getPid().ToString()), "cmdline");\r
- StreamReader stream = File.OpenText(path);\r
- string res = stream.ReadToEnd();\r
- stream.Close();\r
- return res;\r
- }\r
- }\r
-\r
- public string MachineName\r
- {\r
- get\r
- {\r
- return GetEnvironmentVariable("HOSTNAME");\r
- }\r
- }\r
-\r
- public OperatingSystem OSVersion\r
- {\r
- get\r
- {\r
- return null;\r
- }\r
- }\r
-\r
- // System.Path services\r
-\r
- public string ChangeExtension(string path, string extension)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:ChangeExtension(System.String, System.String): Stub Method");\r
- return null;\r
- }\r
-\r
- public string GetExtension(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetExtension(System.String): Stub Method");\r
- return null;\r
- }\r
-\r
- public string GetFileName(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetFileName(System.String): Stub Method");\r
- return null;\r
- }\r
- \r
- public string GetFileNameWithoutExtension(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetFileNameWithoutExtension(System.String): Stub Method");\r
- return null;\r
- }\r
-\r
- public string GetFullPath(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetFullPath(System.String): Stub Method");\r
- return null;\r
- }\r
-\r
- public string GetPathRoot(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetPathRoot(System.String): Stub Method");\r
- return null;\r
-\r
- }\r
- \r
- public string GetTempFileName()\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetTempFileName(): Stub Method");\r
- return null;\r
- }\r
- \r
- public string GetTempPath()\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetTempPath(): Stub Method");\r
- return null;\r
- }\r
-\r
- public bool HasExtension(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:HasExtension(System.String): Stub Method");\r
- return false;\r
- }\r
-\r
- public bool IsPathRooted(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:IsPathRooted(System.String): Stub Method");\r
- return false;\r
- }\r
-\r
-\r
-\r
- // System.Directory services\r
-\r
- public void DeleteDirectory(string path, bool recursive)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:DeleteDirectory(System.String, System.Boolean): Stub Method");\r
- }\r
-\r
- public bool ExistsDirectory(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:ExistsDirectory(System.String): Stub Method");\r
- return false;\r
- }\r
-\r
- public DateTime GetCreationTimeDirectory(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetCreationTimeDirectory(System.String): Stub Method");\r
- return new DateTime(0);\r
- }\r
-\r
+ {
+ private Hashtable _environment = null;
+
+ //----------------------------------
+ // Class Constants
+ //----------------------------------
+ private const int EOF = -1; // TODO: Linux: Is this true?
+
+
+ // For StdInputStream and StdOutputStream
+ private IntPtr Stdin;
+ private IntPtr Stdout;
+ private IntPtr Stderr;
+
+ //----------------------------------
+ // Class Fields
+ //----------------------------------
+
+ //----------------------------------
+ // Class Constructor
+ //----------------------------------
+ public OpSys()
+ {
+ Stdin=GetStdHandle(0);
+ Stdout=GetStdHandle(1);
+ Stderr=GetStdHandle(2);
+ }
+
+
+ //-------------------------------------------------
+ // Environment Services
+ //-------------------------------------------------
+
+ public string NewLineSequence
+ {
+ get
+ {
+ return "\n";
+ }
+ }
+
+ public char DirectorySeparator
+ {
+ get
+ {
+ return '/';
+ }
+ }
+
+ public char AltDirectorySeparator
+ {
+ get
+ {
+ return '\\';
+ }
+ }
+
+ public char VolumeSeparator
+ {
+ get
+ {
+ return '/';
+ }
+ }
+
+ public char PathSeparator
+ {
+ get
+ {
+ return ':';
+ }
+ }
+
+ public char[] InvalidPathChars
+ {
+ get
+ {
+ return new char[] { '\0' };
+ }
+ }
+
+ public char[] DirVolSeparatorChars
+ {
+ get
+ {
+ return new char[] { this.DirectorySeparator, this.AltDirectorySeparator, this.VolumeSeparator};
+ }
+ }
+ public char ExtensionCharacter
+ {
+ get
+ {
+ return '.';
+ }
+ }
+
+ public string GetEnvironmentVariable(string eVar)
+ {
+ return EnvironmentVariables[eVar].ToString();
+ }
+
+ public IDictionary EnvironmentVariables
+ {
+ get
+ {
+ if (_environment == null) {
+ IntPtr pp = _getEnviron(); // pointer to an array of char*
+ _environment = new Hashtable();
+
+ if (pp != IntPtr.Zero) {
+ IntPtr p;
+ bool done = false;
+ char[] delimiter = { '=' };
+
+ while (!done)
+ {
+ p = Marshal.ReadIntPtr(pp);
+ if (p != IntPtr.Zero)
+ {
+ string str = Marshal.PtrToStringAuto(p);
+ string[] ar = str.Split(delimiter, 2);
+ switch(ar.Length)
+ {
+ case 1:
+ _environment.Add(ar[0], "");
+ break;
+ case 2:
+ _environment.Add(ar[0], ar[1]);
+ break;
+ default:
+ System.Diagnostics.Debug.Assert(false); // this shouldn't happen
+ break;
+ }
+ }
+ else
+ {
+ done = true;
+ }
+ }
+ }
+ }
+ return _environment;
+ }
+ }
+
+ public string CommandLine
+ {
+ get
+ {
+ string path = Path.Combine(Path.Combine("/proc", _getPid().ToString()), "cmdline");
+ StreamReader stream = File.OpenText(path);
+ string res = stream.ReadToEnd();
+ stream.Close();
+ return res;
+ }
+ }
+
+ public string MachineName
+ {
+ get
+ {
+ return GetEnvironmentVariable("HOSTNAME");
+ }
+ }
+
+ public OperatingSystem OSVersion
+ {
+ get
+ {
+ return null;
+ }
+ }
+
+ // System.Path services
+
+ public string ChangeExtension(string path, string extension)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:ChangeExtension(System.String, System.String): Stub Method");
+ return null;
+ }
+
+ public string GetExtension(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetExtension(System.String): Stub Method");
+ return null;
+ }
+
+ public string GetFileName(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetFileName(System.String): Stub Method");
+ return null;
+ }
+
+ public string GetFileNameWithoutExtension(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetFileNameWithoutExtension(System.String): Stub Method");
+ return null;
+ }
+
+ public string GetFullPath(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetFullPath(System.String): Stub Method");
+ return null;
+ }
+
+ public string GetPathRoot(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetPathRoot(System.String): Stub Method");
+ return null;
+
+ }
+
+ public string GetTempFileName()
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetTempFileName(): Stub Method");
+ return null;
+ }
+
+ public string GetTempPath()
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetTempPath(): Stub Method");
+ return null;
+ }
+
+ public bool HasExtension(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:HasExtension(System.String): Stub Method");
+ return false;
+ }
+
+ public bool IsPathRooted(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:IsPathRooted(System.String): Stub Method");
+ return false;
+ }
+
+
+
+ // System.Directory services
+
+ public void DeleteDirectory(string path, bool recursive)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:DeleteDirectory(System.String, System.Boolean): Stub Method");
+ }
+
+ public bool ExistsDirectory(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:ExistsDirectory(System.String): Stub Method");
+ return false;
+ }
+
+ public DateTime GetCreationTimeDirectory(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetCreationTimeDirectory(System.String): Stub Method");
+ return new DateTime(0);
+ }
+
[System.Runtime.CompilerServices.MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
public extern string GetCurrentDirectory();
- public string[] GetDirectories(string path, string searchPattern)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetDirectories(System.String,System.String): Stub Method");\r
- return null;\r
- }\r
-\r
- public string[] GetFiles(string path, string searchPattern)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetFiles(System.String, System.String): Stub Method");\r
- return null;\r
- }\r
-\r
- public string[] GetFileSystemEntries(string path, string searchPattern)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetFileSystemEntries(System.String, System.String): Stub Method");\r
- return null;\r
- }\r
-\r
- public DateTime GetLastAccessTimeDirectory(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetLastAccessTimeDirectory(System.String): Stub Method");\r
- return new DateTime(0);\r
- }\r
-\r
- public DateTime GetLastWriteTimeDirectory(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetLastWriteTimeDirectory(System.String): Stub Method");\r
- return new DateTime(0);\r
- }\r
-\r
- public void MoveDirectory(string sourceDirName, string destDirName)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:MoveDirectory(System.String, System.String): Stub Method");\r
- }\r
-\r
- public void SetCreationTimeDirectory(string path, DateTime creationTime)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:SetCreationTimeDirectory(System.String, System.DateTime): Stub Method");\r
- }\r
-\r
- public void SetCurrentDirectory(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:SetCurrentDirectory(System.String): Stub Method");\r
- }\r
-\r
- public void SetLastAccessTimeDirectory(string path, DateTime lastAccessTime)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:SetLastAccessTimeDirectory(System.String, System.DateTime): Stub Method");\r
- }\r
-\r
- public void SetLastWriteTimeDirectory(string path, DateTime lastWriteTime)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:SetLastWriteTimeDirectory(System.String, System.DateTime): Stub Method");\r
- }\r
-\r
- //-----------------------------------\r
- // I/O Services\r
- //-----------------------------------\r
-\r
- // For StdInputStream\r
- public int ReadStdInput(byte[] buffer, int offset, int count)\r
- {\r
- return ReadFile(new IntPtr(STDIN), buffer, offset, count);\r
- }\r
-\r
- // For StdOutputStream\r
- public void FlushStdOutput(byte[] byteBuf)\r
- {\r
- FlushFile(new IntPtr(STDOUT), byteBuf);\r
- }\r
-\r
- public unsafe int ReadFile(IntPtr handle, byte[] buffer, int offset, int count)\r
- {\r
- int res;\r
-\r
- fixed (void *p = &buffer [offset]) {\r
- res = _read(handle, p, count);\r
- }\r
- \r
- return res;\r
- }\r
-\r
- public unsafe int WriteFile(IntPtr handle, byte[] buffer, int offset, int count)\r
- {\r
- int res;\r
-\r
- fixed (void *p = &buffer [offset]) {\r
- res = _write(handle, p, count);\r
- }\r
-\r
- return res;\r
- }\r
-\r
- public int SetLengthFile(IntPtr handle, long length)\r
- {\r
- return _ftruncate (handle, (int)length);\r
- }\r
-\r
- public void FlushFile(IntPtr handle, byte[] byteBuf)\r
- {\r
- WriteFile(handle, byteBuf, 0, byteBuf.Length);\r
- }\r
-\r
- public IntPtr OpenFile(string path, FileMode mode, FileAccess access, FileShare share)\r
- {\r
- int flags = _getUnixFlags (mode, access);\r
-\r
- return _open (path, flags, 0x1a4);\r
- }\r
- \r
- public void CloseFile(IntPtr handle)\r
- {\r
- _close (handle);\r
- }\r
- \r
- public long SeekFile(IntPtr handle, long offset, SeekOrigin origin)\r
- {\r
- switch (origin) {\r
- case SeekOrigin.End:\r
- return _lseek (handle, (int)offset, SEEK_END);\r
- case SeekOrigin.Current:\r
- return _lseek (handle, (int)offset, SEEK_CUR);\r
- default:\r
- return _lseek (handle, (int)offset, SEEK_SET);\r
- }\r
- \r
- }\r
- \r
- public IntPtr CreateFile(string path, FileMode mode, FileAccess access, FileShare share)\r
- {\r
- return OpenFile(path, FileMode.CreateNew, access, share);\r
- }\r
- \r
- public void DeleteFile(string path)\r
- {\r
- _unlink(path);\r
- }\r
- \r
- public bool ExistsFile(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:ExistsFile(System.String): Stub Method");\r
- return false;\r
- }\r
- \r
- public DateTime GetCreationTimeFile(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetCreationTimeFile(System.String): Stub Method");\r
- return new DateTime(0);\r
- }\r
- \r
- public DateTime GetLastAccessTimeFile(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetLastAccessTimeFile(System.String): Stub Method");\r
- return new DateTime(0);\r
- }\r
- \r
- public DateTime GetLastWriteTimeFile(string path)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:GetLastWriteFile(System.String): Stub Method");\r
- return new DateTime(0);\r
- }\r
- \r
- public void SetCreationTimeFile(string path, DateTime creationTime)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:SetCreationTimeFile(System.String, System.DateTime): Stub Method");\r
- }\r
- \r
- public void SetLastAccessTimeFile(string path, DateTime lastAccessTime)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:SetLastAccessTimeFile(System.String, System.DateTime): Stub Method");\r
- }\r
- \r
- public void SetLastWriteTimeFile(string path, DateTime lastWriteTime)\r
- {\r
- System.Diagnostics.Debug.WriteLine("Linux:SetCLastWriteTimeFile(System.String, System.DateTime): Stub Method");\r
- }\r
-\r
-\r
- public long FileLength(string path)\r
- {\r
- return 0;\r
- }\r
-\r
- public long FileLength(IntPtr handle)\r
- {\r
- return 0;\r
- }\r
-\r
- // Private implementation details\r
- [DllImport("monowrapper", EntryPoint="mono_wrapper_environ", CharSet=CharSet.Ansi)]\r
- private unsafe static extern IntPtr _getEnviron();\r
-\r
- [DllImport("libc", EntryPoint="getpid")]\r
- private unsafe static extern int _getPid();\r
-\r
- [DllImport("libc", EntryPoint="read", CharSet=CharSet.Ansi)]\r
- private unsafe static extern int _read(IntPtr fd, void * buf, int count);\r
-\r
- [DllImport("libc", EntryPoint="write", CharSet=CharSet.Ansi)]\r
- private unsafe static extern int _write(IntPtr fd, void * buf, int count);\r
-\r
- [DllImport("libc", EntryPoint="ftruncate", CharSet=CharSet.Ansi)]\r
- private unsafe static extern int _ftruncate(IntPtr fd, int count);\r
-\r
- [DllImport("libc", EntryPoint="lseek", CharSet=CharSet.Ansi)]\r
- private unsafe static extern int _lseek(IntPtr fd, int offset, int whence);\r
-\r
- [DllImport("libc", EntryPoint="fflush", CharSet=CharSet.Ansi)]\r
- private unsafe static extern int _fflush(IntPtr fd);\r
-\r
- [DllImport("libc", EntryPoint="close", CharSet=CharSet.Ansi)]\r
- private unsafe static extern int _close(IntPtr fd);\r
-\r
- [DllImport("libc", EntryPoint="open", CharSet=CharSet.Ansi)]\r
- private unsafe static extern IntPtr _open(string path, int flags, int mode);\r
-\r
- [DllImport("libc", EntryPoint="unlink", CharSet=CharSet.Ansi)]\r
- private unsafe static extern int _unlink(string path);\r
-\r
- private const int O_RDONLY = 0x00000000;
- private const int O_WRONLY = 0x00000001;
- private const int O_RDWR = 0x00000002;
- private const int O_CREAT = 0x00000040;
- private const int O_EXCL = 0x00000080;
- private const int O_TRUNC = 0x00000200;
- private const int O_APPEND = 0x00000400;
-
- private const int SEEK_SET = 0;
- private const int SEEK_CUR = 1;
- private const int SEEK_END = 2;
-\r
- private int _getUnixFlags (FileMode mode, FileAccess access)\r
- {\r
- int flags = 0;\r
- switch (access) {\r
- case FileAccess.Read:\r
- flags = O_RDONLY;\r
- break;\r
- case FileAccess.Write:\r
- flags = O_WRONLY;\r
- break;\r
- case FileAccess.ReadWrite:\r
- flags = O_RDWR;\r
- break;\r
- }\r
-\r
- switch (mode) {\r
- case FileMode.Append:\r
- flags |= O_APPEND;\r
- break;\r
- case FileMode.Create:\r
- flags |= O_CREAT;\r
- break;\r
- case FileMode.CreateNew:\r
- flags |= O_CREAT | O_EXCL;\r
- break;\r
- case FileMode.Open:\r
- break;\r
- case FileMode.OpenOrCreate:\r
- flags |= O_CREAT;\r
- break;\r
- case FileMode.Truncate:\r
- flags |= O_TRUNC;\r
- break;\r
- }\r
-\r
- return flags;\r
- }\r
+ public string[] GetDirectories(string path, string searchPattern)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetDirectories(System.String,System.String): Stub Method");
+ return null;
+ }
+
+ public string[] GetFiles(string path, string searchPattern)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetFiles(System.String, System.String): Stub Method");
+ return null;
+ }
+
+ public string[] GetFileSystemEntries(string path, string searchPattern)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetFileSystemEntries(System.String, System.String): Stub Method");
+ return null;
+ }
+
+ public DateTime GetLastAccessTimeDirectory(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetLastAccessTimeDirectory(System.String): Stub Method");
+ return new DateTime(0);
+ }
+
+ public DateTime GetLastWriteTimeDirectory(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:GetLastWriteTimeDirectory(System.String): Stub Method");
+ return new DateTime(0);
+ }
+
+ public void MoveDirectory(string sourceDirName, string destDirName)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:MoveDirectory(System.String, System.String): Stub Method");
+ }
+
+ public void SetCreationTimeDirectory(string path, DateTime creationTime)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:SetCreationTimeDirectory(System.String, System.DateTime): Stub Method");
+ }
+
+ public void SetCurrentDirectory(string path)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:SetCurrentDirectory(System.String): Stub Method");
+ }
+
+ public void SetLastAccessTimeDirectory(string path, DateTime lastAccessTime)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:SetLastAccessTimeDirectory(System.String, System.DateTime): Stub Method");
+ }
+
+ public void SetLastWriteTimeDirectory(string path, DateTime lastWriteTime)
+ {
+ System.Diagnostics.Debug.WriteLine("Linux:SetLastWriteTimeDirectory(System.String, System.DateTime): Stub Method");
+ }
+
+ //-----------------------------------
+ // I/O Services
+ //-----------------------------------
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ private extern IntPtr GetStdHandle(int fd);
+
+ public IntPtr StdinHandle {
+ get {
+ return(Stdin);
+ }
+ }
+
+ public IntPtr StdoutHandle {
+ get {
+ return(Stdout);
+ }
+ }
+
+ public IntPtr StderrHandle {
+ get {
+ return(Stderr);
+ }
+ }
+
+
+ // For StdInputStream
+ public int ReadStdInput(byte[] buffer, int offset, int count)
+ {
+ return ReadFile(StdinHandle, buffer, offset, count);
+ }
+
+ // For StdOutputStream
+ public void FlushStdOutput(byte[] byteBuf)
+ {
+ FlushFile(StdoutHandle, byteBuf);
+ }
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern int ReadFile(IntPtr handle, byte[] buffer, int offset, int count);
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern int WriteFile(IntPtr handle, byte[] buffer, int offset, int count);
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern int SetLengthFile(IntPtr handle, long length);
+
+ public void FlushFile(IntPtr handle, byte[] byteBuf)
+ {
+ WriteFile(handle, byteBuf, 0, byteBuf.Length);
+ }
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern IntPtr OpenFile(String path, FileMode mode, FileAccess access, FileShare share);
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern void CloseFile(IntPtr handle);
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern long SeekFile(IntPtr handle, long offset, SeekOrigin origin);
+
+ public IntPtr CreateFile(string path, FileMode mode, FileAccess access, FileShare share)
+ {
+ return OpenFile(path, FileMode.CreateNew, access, share);
+ }
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern void DeleteFile(string path);
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ public extern bool ExistsFile(string path);
+
+ /* The long time parameters in GetFileTime and
+ * SetFileTime correspond to Windows file times (ticks
+ * from DateTime(1/1/1601 00:00 GMT))
+ */
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ private extern bool GetFileTime(IntPtr handle, out long creat, out long lastaccess, out long lastwrite);
+
+ [MethodImplAttribute(System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]
+ private extern bool SetFileTime(IntPtr handle, long creat, long lastaccess, long lastwrite);
+
+ public DateTime GetCreationTimeFile(string path)
+ {
+ long creat, lastaccess, lastwrite;
+ bool ret;
+ FileStream s = new FileStream(path, FileMode.Open, FileAccess.Read);
+
+ ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
+ s.Close();
+
+ return DateTime.FromFileTime(creat);
+ }
+
+ public DateTime GetLastAccessTimeFile(string path)
+ {
+ long creat, lastaccess, lastwrite;
+ bool ret;
+ FileStream s = new FileStream(path, FileMode.Open, FileAccess.Read);
+
+ ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
+ s.Close();
+
+ return DateTime.FromFileTime(lastaccess);
+ }
+
+ public DateTime GetLastWriteTimeFile(string path)
+ {
+ long creat, lastaccess, lastwrite;
+ bool ret;
+ FileStream s = new FileStream(path, FileMode.Open, FileAccess.Read);
+
+ ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
+ s.Close();
+
+ return DateTime.FromFileTime(lastwrite);
+ }
+
+ public void SetCreationTimeFile(string path, DateTime creationTime)
+ {
+ long creat, lastaccess, lastwrite;
+ bool ret;
+ FileStream s = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
+
+ // Get the existing times first
+ ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
+
+ creat=creationTime.ToFileTime();
+
+ ret=SetFileTime(s.Handle, creat, lastaccess, lastwrite);
+ s.Close();
+ }
+
+ public void SetLastAccessTimeFile(string path, DateTime lastAccessTime)
+ {
+ long creat, lastaccess, lastwrite;
+ bool ret;
+ FileStream s = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
+
+ // Get the existing times first
+ ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
+
+ lastaccess=lastAccessTime.ToFileTime();
+
+ ret=SetFileTime(s.Handle, creat, lastaccess, lastwrite);
+ s.Close();
+ }
+
+ public void SetLastWriteTimeFile(string path, DateTime lastWriteTime)
+ {
+ long creat, lastaccess, lastwrite;
+ bool ret;
+ FileStream s = new FileStream(path, FileMode.Open, FileAccess.ReadWrite);
+
+ // Get the existing times first
+ ret=GetFileTime(s.Handle, out creat, out lastaccess, out lastwrite);
+
+ lastwrite=lastWriteTime.ToFileTime();
+
+ ret=SetFileTime(s.Handle, creat, lastaccess, lastwrite);
+ s.Close();
+ }
+
+
+ public long FileLength(string path)
+ {
+ return 0;
+ }
+
+ public long FileLength(IntPtr handle)
+ {
+ return 0;
+ }
+
+ // Private implementation details
+ [DllImport("monowrapper", EntryPoint="mono_wrapper_environ", CharSet=CharSet.Ansi)]
+ private unsafe static extern IntPtr _getEnviron();
+
+ [DllImport("libc", EntryPoint="getpid")]
+ private unsafe static extern int _getPid();
[ DllImport("libm", EntryPoint="acos") ]
public extern static double Acos(double d);
[ DllImport("libm", EntryPoint="tanh") ]
public extern static double Tanh(double d);
- }\r
-}\r
+ }
+}