File.cs 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. //------------------------------------------------------------------------------
  2. //
  3. // System.IO.File.cs
  4. //
  5. // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved
  6. //
  7. // Author: Jim Richardson, [email protected]
  8. // Created: Monday, August 22, 2001
  9. //
  10. // TODO: Research exceptions for all methods
  11. //------------------------------------------------------------------------------
  12. using System;
  13. namespace System.IO
  14. {
  15. /// <summary>
  16. ///
  17. /// </summary>
  18. public sealed class File : Object
  19. {
  20. /// <summary>
  21. /// Creates a StreamWriter that appends text to a file creating the file if needed
  22. /// </summary>
  23. public static StreamWriter AppendText(string path)
  24. { // TODO: Implement
  25. return null;
  26. }
  27. /// <summary>
  28. /// Copies a file overwriting existing if necessary
  29. /// </summary>
  30. public static void Copy(string sourceFilename, string destFilename)
  31. {
  32. Copy(sourceFilename, destFilename, true);
  33. }
  34. /// <summary>
  35. /// Copies a file overwriting existing if specified
  36. /// </summary>
  37. public static void Copy(string sourceFilename, string destFilename, bool bOverwrite)
  38. { // TODO: Implement
  39. }
  40. /// <summary>
  41. /// Creates a file given the fully qualified path
  42. /// </summary>
  43. public static FileStream Create(string path)
  44. { // TODO: Research default buffersize
  45. return Create(path, 1024);
  46. }
  47. /// <summary>
  48. /// Creates a file given the fully qualified path using specified buffersize
  49. /// </summary>
  50. public static FileStream Create(string path, int buffersize)
  51. { // TODO: Implement
  52. return null;
  53. }
  54. /// <summary>
  55. /// Delete a file
  56. /// </summary>
  57. public static void Delete(string path)
  58. { // TODO: Implement
  59. }
  60. /// <summary>
  61. /// Returns true if file exists on disk
  62. /// </summary>
  63. public static bool Exists(string path)
  64. { // TODO: Implement
  65. return false;
  66. }
  67. /// <summary>
  68. /// Returns the date and time the file specified by path was created
  69. /// </summary>
  70. public static DateTime GetCreationTime(string path)
  71. {
  72. return DateTime.MinValue;
  73. }
  74. /// <summary>
  75. /// Returns the date and time the file specified by path was created
  76. /// </summary>
  77. public static FileAttributes GetAttributes(string path)
  78. {
  79. FileInfo fInfo = new FileInfo(path);
  80. return fInfo.Attributes;
  81. }
  82. /// <summary>
  83. /// Returns an array of directories in the file specified by path
  84. /// </summary>
  85. public static string[] GetDirectories(string path)
  86. {
  87. return null;
  88. }
  89. /// <summary>
  90. /// Returns an array of directories in the file specified by path
  91. /// matching the filter specified by mask
  92. /// </summary>
  93. public static string[] GetDirectories(string path, string mask)
  94. {
  95. return null;
  96. }
  97. /// <summary>
  98. /// Returns the root of the specified path
  99. /// </summary>
  100. public static string GetDirectoryRoot(string path)
  101. {
  102. return null;
  103. }
  104. /// <summary>
  105. /// Returns an array of files in the file specified by path
  106. /// </summary>
  107. public static string[] GetFiles(string path)
  108. {
  109. return null;
  110. }
  111. /// <summary>
  112. /// Returns an array of files in the file specified by path
  113. /// matching the filter specified by mask
  114. /// </summary>
  115. public static string[] GetFiles(string path, string mask)
  116. {
  117. return null;
  118. }
  119. /// <summary>
  120. /// Returns an array of filesystementries in the file specified by path
  121. /// </summary>
  122. public static string[] GetFileSystemEntries(string path)
  123. {
  124. return null;
  125. }
  126. /// <summary>
  127. /// Returns an array of filesystementries in the file specified by path
  128. /// matching the filter specified by mask
  129. /// </summary>
  130. public static string[] GetFileSystemEntries(string path, string mask)
  131. {
  132. return null;
  133. }
  134. /// <summary>
  135. /// Returns the date and time the file specified by path was last accessed
  136. /// </summary>
  137. public static DateTime GetLastAccessTime(string path)
  138. {
  139. return DateTime.MinValue;
  140. }
  141. /// <summary>
  142. /// Returns the date and time the file specified by path was last modified
  143. /// </summary>
  144. public static DateTime GetLastWriteTime(string path)
  145. {
  146. return DateTime.MinValue;
  147. }
  148. /// <summary>
  149. /// Returns an array of logical drives on this system
  150. /// </summary>
  151. public static string[] GetLogicalDrives()
  152. {
  153. return null;
  154. }
  155. /// <summary>
  156. /// Returns the parent file of the file specified by path
  157. /// </summary>
  158. public static DirectoryInfo GetParent(string path)
  159. {
  160. return null;
  161. }
  162. /// <summary>
  163. /// Moves a file and its contents
  164. /// </summary>
  165. public static void Move(string srcDirName, string destDirName)
  166. {
  167. }
  168. /// <summary>
  169. /// Sets the creation time of the file specified by path
  170. /// </summary>
  171. public static void SetCreationTime(string path, DateTime creationTime)
  172. {
  173. }
  174. /// <summary>
  175. /// Sets the current file to the file specified by path
  176. /// </summary>
  177. public static void SetCurrentDirectory(string path)
  178. {
  179. }
  180. /// <summary>
  181. /// Sets the last access time of the file specified by path
  182. /// </summary>
  183. public static void SetLastAccessTime(string path, DateTime accessTime)
  184. {
  185. }
  186. /// <summary>
  187. /// Sets the last write time of the file specified by path
  188. /// </summary>
  189. public static void SetLastWriteTime(string path, DateTime modifiedTime)
  190. {
  191. }
  192. }
  193. }
  194. //------------------------------------------------------------------------------
  195. //
  196. // System.IO.Directory.cs
  197. //
  198. // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved
  199. //
  200. // Author: Jim Richardson, [email protected]
  201. // Created: Monday, August 13, 2001
  202. //
  203. //------------------------------------------------------------------------------
  204. using System;
  205. namespace System.IO
  206. {
  207. /// <summary>
  208. ///
  209. /// </summary>
  210. public sealed class Directory : Object
  211. {
  212. /// <summary>
  213. /// Creates all directories not existing in path
  214. /// </summary>
  215. public static DirectoryInfo CreateDirectory(string path)
  216. {
  217. return null;
  218. }
  219. /// <summary>
  220. /// Delete an empty directory
  221. /// </summary>
  222. public static void Delete(string path)
  223. {
  224. }
  225. /// <summary>
  226. /// Delete a directory, and contents if bRecurse is true
  227. /// </summary>
  228. public static void Delete(string path, bool bRecurse)
  229. {
  230. }
  231. /// <summary>
  232. /// Returns true if directory exists on disk
  233. /// </summary>
  234. public static bool Exists(string path)
  235. {
  236. return false;
  237. }
  238. /// <summary>
  239. /// Returns the date and time the directory specified by path was created
  240. /// </summary>
  241. public static DateTime GetCreationTime(string path)
  242. {
  243. return getInfo().GetCreationTime(path);
  244. }
  245. /// <summary>
  246. /// Returns the date and time the directory specified by path was last accessed
  247. /// </summary>
  248. public static DateTime GetLastAccessTime(string path)
  249. {
  250. return getInfo().GetLastWriteTime(path);
  251. }
  252. /// <summary>
  253. /// Returns the date and time the directory specified by path was last modified
  254. /// </summary>
  255. public static DateTime GetLastWriteTime(string path)
  256. {
  257. return getInfo().GetLastWriteTime(path);
  258. }
  259. /// <summary>
  260. /// Moves a file
  261. /// </summary>
  262. public static void Move(string srcFilename, string destFilename)
  263. {
  264. getInfo(srcFilename).MoveTo(destFilename);
  265. }
  266. /// <summary>
  267. /// Open a file for exclusive reading and writing
  268. /// </summary>
  269. public FileStream Open(string path, FileMode mode)
  270. { // TODO: research if exclusive is the correct default
  271. return getInfo(path).Open(mode, FileAccess.ReadWrite);
  272. }
  273. /// <summary>
  274. /// Open a file for exclusive access specified by mode
  275. /// </summary>
  276. public FileStream Open(string path, FileMode mode, FileAccess access)
  277. { // TODO: research if exclusive is the correct default
  278. return getInfo(path).Open(mode, access, FileShare.None);
  279. }
  280. /// <summary>
  281. /// Open a file access specified by mode, sharing specified by share
  282. /// </summary>
  283. public FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)
  284. {
  285. return getInfo(path).Open(mode, access, share);
  286. }
  287. /// <summary>
  288. /// Open a FileStream for reading and writing
  289. /// </summary>
  290. public FileStream OpenRead(string path)
  291. { // TODO: find out what default share should be
  292. return getInfo(path).OpenRead();
  293. }
  294. /// <summary>
  295. /// Open a StreamReader
  296. /// </summary>
  297. public StreamReader OpenText(string path)
  298. {
  299. return getInfo(path).OpenText();
  300. }
  301. /// <summary>
  302. /// Open a FileStream for reading and writing
  303. /// </summary>
  304. public FileStream OpenWrite(string path)
  305. {
  306. return getInfo(path).OpenWrite();
  307. }
  308. /// <summary>
  309. /// Sets the attributes of file specified by path
  310. /// </summary>
  311. public static void SetAttributes(string path, FileAttributes attributes)
  312. {
  313. getInfo().Attributes = attributes;
  314. }
  315. /// <summary>
  316. /// Sets the creation time of the directory specified by path
  317. /// </summary>
  318. public static void SetCreationTime(string path, DateTime creationTime)
  319. {
  320. getInfo().SetCreationTime(path, creationTime);
  321. }
  322. /// <summary>
  323. /// Sets the last access time of the directory specified by path
  324. /// </summary>
  325. public static void SetLastAccessTime(string path, DateTime accessTime)
  326. {
  327. getInfo().SetLastAccessTime(path, accessTime);
  328. }
  329. /// <summary>
  330. /// Sets the last write time of the directory specified by path
  331. /// </summary>
  332. public static void SetLastWriteTime(string path, DateTime modifiedTime)
  333. {
  334. getInfo().SetLastWriteTime(path, modifiedTime);
  335. }
  336. private static FileInfo getInfo(string path)
  337. {
  338. return new FileInfo(path);
  339. }
  340. }
  341. }