Added missing Exceptions in System.IO and System.Security.Policy
[mono.git] / mcs / class / corlib / System.IO / File.cs
1 //------------------------------------------------------------------------------\r
2 // \r
3 // System.IO.File.cs \r
4 //\r
5 // Copyright (C) 2001 Moonlight Enterprises, All Rights Reserved\r
6 // \r
7 // Author:         Jim Richardson, develop@wtfo-guru.com\r
8 // Created:        Monday, August 22, 2001 \r
9 //\r
10 // TODO: Research exceptions for all methods\r
11 //------------------------------------------------------------------------------\r
12 \r
13 using System;\r
14 \r
15 namespace System.IO\r
16 {\r
17         /// <summary>\r
18         /// \r
19         /// </summary>\r
20         public sealed class File : Object\r
21         { \r
22                 /// <summary>\r
23                 /// Creates a StreamWriter that appends text to a file creating the file if needed\r
24                 /// </summary>\r
25                 [MonoTODO]\r
26                 public static StreamWriter AppendText(string path)\r
27                 {       // TODO: Implement\r
28                         return null;\r
29                 }\r
30                  \r
31                 /// <summary>\r
32                 /// Copies a file overwriting existing if necessary\r
33                 /// </summary>\r
34                 public static void Copy(string sourceFilename, string destFilename)\r
35                 {\r
36                         Copy(sourceFilename, destFilename, true);\r
37                 }\r
38                  \r
39                 /// <summary>\r
40                 /// Copies a file overwriting existing if specified\r
41                 /// </summary>\r
42                 [MonoTODO]\r
43                 public static void Copy(string sourceFilename, string destFilename, bool bOverwrite)\r
44                 {       // TODO: Implement\r
45                 }\r
46 \r
47                 /// <summary>\r
48                 /// Creates a file given the fully qualified path\r
49                 /// </summary>\r
50                 [MonoTODO]\r
51                 public static FileStream Create(string path)\r
52                 {       // TODO: Research default buffersize\r
53                         return Create(path, 1024);\r
54                 }\r
55 \r
56                 /// <summary>\r
57                 /// Creates a file given the fully qualified path using specified buffersize\r
58                 /// </summary>\r
59                 [MonoTODO]\r
60                 public static FileStream Create(string path, int buffersize)\r
61                 {       // TODO: Implement\r
62                         return null;\r
63                 }\r
64                 \r
65                 /// <summary>\r
66                 /// Delete a file\r
67                 /// </summary>\r
68                 [MonoTODO]\r
69                 public static void Delete(string path)\r
70                 {       // TODO: Implement\r
71                 }\r
72                 \r
73                 /// <summary>\r
74                 /// Returns true if file exists on disk\r
75                 /// </summary>\r
76                 [MonoTODO]\r
77                 public static bool Exists(string path)\r
78                 {       // TODO: Implement\r
79                         return false;\r
80                 }\r
81                 \r
82                 /// <summary>\r
83                 /// Returns the date and time the file specified by path was created\r
84                 /// </summary>\r
85                 public static FileAttributes GetAttributes(string path)\r
86                 {\r
87                         FileInfo fInfo = new FileInfo(path);\r
88                         return fInfo.Attributes;\r
89                 }\r
90 \r
91                 /// <summary>\r
92                 /// Returns the date and time the directory specified by path was created\r
93                 /// </summary>\r
94                 public static DateTime GetCreationTime(string path)\r
95                 {\r
96                         return getInfo(path).CreationTime;\r
97                 }\r
98 \r
99                 /// <summary>\r
100                 /// Returns the date and time the directory specified by path was last accessed\r
101                 /// </summary>\r
102                 public static DateTime GetLastAccessTime(string path)\r
103                 {\r
104                         return getInfo(path).LastAccessTime;\r
105                 }\r
106 \r
107                 /// <summary>\r
108                 /// Returns the date and time the directory specified by path was last modified\r
109                 /// </summary>\r
110                 public static DateTime GetLastWriteTime(string path)\r
111                 {\r
112                         return getInfo(path).LastWriteTime;\r
113                 }\r
114                 \r
115                 /// <summary>\r
116                 /// Moves a file\r
117                 /// </summary>\r
118                 public static void Move(string srcFilename, string destFilename)\r
119                 {\r
120                         getInfo(srcFilename).MoveTo(destFilename);\r
121                 }\r
122                 \r
123                 /// <summary>\r
124                 /// Open a file for exclusive reading and writing\r
125                 /// </summary>\r
126                 [MonoTODO]\r
127                 public static FileStream Open(string path, FileMode mode)\r
128                 {       // TODO: research if exclusive is the correct default\r
129                         return getInfo(path).Open(mode, FileAccess.ReadWrite);\r
130                 }\r
131                 \r
132                 /// <summary>\r
133                 /// Open a file for exclusive access specified by mode\r
134                 /// </summary>\r
135                 [MonoTODO]\r
136                 public static FileStream Open(string path, FileMode mode, FileAccess access)\r
137                 {       // TODO: research if exclusive is the correct default\r
138                         return getInfo(path).Open(mode, access, FileShare.None);\r
139                 }\r
140                 \r
141                 /// <summary>\r
142                 /// Open a file access specified by mode, sharing specified by share\r
143                 /// </summary>\r
144                 public static FileStream Open(string path, FileMode mode, FileAccess access, FileShare share)\r
145                 {\r
146                         return getInfo(path).Open(mode, access, share);\r
147                 }\r
148                 \r
149                 /// <summary>\r
150                 /// Open a FileStream for reading and writing\r
151                 /// </summary>\r
152                 [MonoTODO]\r
153                 public static FileStream OpenRead(string path)\r
154                 {       // TODO: find out what default share should be\r
155                         return getInfo(path).OpenRead();\r
156                 }\r
157                 \r
158                 /// <summary>\r
159                 /// Open a StreamReader\r
160                 /// </summary>\r
161                 public static StreamReader OpenText(string path)\r
162                 {\r
163                         return getInfo(path).OpenText();\r
164                 }\r
165 \r
166                 /// <summary>\r
167                 /// Open a FileStream for reading and writing\r
168                 /// </summary>\r
169                 public FileStream OpenWrite(string path)\r
170                 {\r
171                         return getInfo(path).OpenWrite();\r
172                 }\r
173                 \r
174                 /// <summary>\r
175                 /// Sets the attributes of file specified by path\r
176                 /// </summary>\r
177                 public static void SetAttributes(string path, FileAttributes attributes)\r
178                 {\r
179                         getInfo(path).Attributes = attributes;\r
180                 }\r
181                 \r
182                 /// <summary>\r
183                 /// Sets the creation time of the directory specified by path\r
184                 /// </summary>\r
185                 public static void SetCreationTime(string path, DateTime creationTime)\r
186                 {\r
187                         getInfo(path).CreationTime = creationTime;\r
188                 }\r
189 \r
190                 /// <summary>\r
191                 /// Sets the last access time of the directory specified by path\r
192                 /// </summary>\r
193                 public static void SetLastAccessTime(string path, DateTime accessTime)\r
194                 {\r
195                         getInfo(path).LastAccessTime = accessTime;\r
196                 }\r
197                 \r
198                 /// <summary>\r
199                 /// Sets the last write time of the directory specified by path\r
200                 /// </summary>\r
201                 public static void SetLastWriteTime(string path, DateTime modifiedTime)\r
202                 {\r
203                         getInfo(path).LastWriteTime = modifiedTime;\r
204                 }\r
205                 \r
206                 private static FileInfo getInfo(string path)\r
207                 {\r
208                         return new FileInfo(path);\r
209                 }\r
210         }\r
211 }\r