2974bd49949ecdd27de60df557c33ee102df61e4
[mono.git] / mono / metadata / file-io.h
1 /*
2  * file-io.h: File IO internal calls
3  *
4  * Authors:
5  *      Dick Porter (dick@ximian.com)
6  *      Dan Lewis (dihlewis@yahoo.co.uk)
7  *
8  * (C) 2001 Ximian, Inc.
9  * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
10  */
11
12 #ifndef _MONO_METADATA_FILEIO_H_
13 #define _MONO_METADATA_FILEIO_H_
14
15 #include <config.h>
16 #include <glib.h>
17
18 #include <mono/metadata/object-internals.h>
19 #include <mono/io-layer/io-layer.h>
20 #include <mono/utils/mono-compiler.h>
21
22 G_BEGIN_DECLS
23
24 /* This is a copy of System.IO.FileAccess */
25 typedef enum {
26         FileAccess_Read=0x01,
27         FileAccess_Write=0x02,
28         FileAccess_ReadWrite=FileAccess_Read|FileAccess_Write
29 } MonoFileAccess;
30
31 /* This is a copy of System.IO.FileMode */
32 typedef enum {
33         FileMode_CreateNew=1,
34         FileMode_Create=2,
35         FileMode_Open=3,
36         FileMode_OpenOrCreate=4,
37         FileMode_Truncate=5,
38         FileMode_Append=6
39 } MonoFileMode;
40
41 /* This is a copy of System.IO.FileShare */
42 typedef enum {
43         FileShare_None=0x0,
44         FileShare_Read=0x01,
45         FileShare_Write=0x02,
46         FileShare_ReadWrite=FileShare_Read|FileShare_Write,
47         FileShare_Delete=0x04
48 } MonoFileShare;
49
50 /* This is a copy of System.IO.FileOptions */
51 typedef enum {
52         FileOptions_None = 0,
53         FileOptions_Temporary = 1,              // Internal.   See note in System.IO.FileOptions
54         FileOptions_Encrypted = 0x4000,
55         FileOptions_DeleteOnClose = 0x4000000,
56         FileOptions_SequentialScan = 0x8000000,
57         FileOptions_RandomAccess = 0x10000000,
58         FileOptions_Asynchronous = 0x40000000,
59         FileOptions_WriteThrough = 0x80000000
60 } MonoFileOptions;
61
62 /* This is a copy of System.IO.SeekOrigin */
63 typedef enum {
64         SeekOrigin_Begin=0,
65         SeekOrigin_Current=1,
66         SeekOrigin_End=2
67 } MonoSeekOrigin;
68
69 /* This is a copy of System.IO.MonoIOStat */
70 typedef struct _MonoIOStat {
71         gint32 attributes;
72         gint64 length;
73         gint64 creation_time;
74         gint64 last_access_time;
75         gint64 last_write_time;
76 } MonoIOStat;
77
78 /* This is a copy of System.IO.FileAttributes */
79 typedef enum {
80         FileAttributes_ReadOnly=0x00001,
81         FileAttributes_Hidden=0x00002,
82         FileAttributes_System=0x00004,
83         FileAttributes_Directory=0x00010,
84         FileAttributes_Archive=0x00020,
85         FileAttributes_Device=0x00040,
86         FileAttributes_Normal=0x00080,
87         FileAttributes_Temporary=0x00100,
88         FileAttributes_SparseFile=0x00200,
89         FileAttributes_ReparsePoint=0x00400,
90         FileAttributes_Compressed=0x00800,
91         FileAttributes_Offline=0x01000,
92         FileAttributes_NotContentIndexed=0x02000,
93         FileAttributes_Encrypted=0x04000,
94         FileAttributes_MonoExecutable= (int) 0x80000000
95 } MonoFileAttributes;
96 /* This is not used anymore
97 typedef struct _MonoFSAsyncResult {
98         MonoObject obj;
99         MonoObject *state;
100         MonoBoolean completed;
101         MonoBoolean done;
102         MonoException *exc;
103         MonoWaitHandle *wait_handle;
104         MonoDelegate *async_callback;
105         MonoBoolean completed_synch;
106         MonoArray *buffer;
107         gint offset;
108         gint count;
109         gint original_count;
110         gint bytes_read;
111         MonoDelegate *real_cb;
112 } MonoFSAsyncResult;
113 */
114 /* System.IO.MonoIO */
115
116 extern MonoBoolean
117 ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error);
118
119 extern MonoBoolean
120 ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error);
121
122 MonoArray *
123 ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
124                                                  MonoString *path_with_pattern,
125                                                  gint mask, gint attrs,
126                                                  gint32 *error);
127
128 extern MonoString *
129 ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
130                                       MonoString *path_with_pattern,
131                                       gint32 *result_mask,
132                                       gint32 *error,
133                                       gpointer *handle);
134 extern MonoString *
135 ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_mask, gint32 *error);
136
137 extern int
138 ves_icall_System_IO_MonoIO_FindClose (gpointer handle);
139
140 extern MonoString *
141 ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error);
142
143 extern MonoBoolean
144 ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
145                                                 gint32 *error);
146
147 extern MonoBoolean
148 ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest,
149                                      gint32 *error);
150
151 extern MonoBoolean
152 ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
153                                      MonoBoolean overwrite, gint32 *error);
154
155 extern MonoBoolean
156 ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error);
157
158 extern gint32 
159 ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error);
160
161 extern MonoBoolean
162 ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
163                                               gint32 *error);
164
165 extern gint32
166 ves_icall_System_IO_MonoIO_GetFileType (HANDLE handle, gint32 *error);
167
168 extern MonoBoolean
169 ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat,
170                                         gint32 *error);
171
172 extern HANDLE 
173 ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
174                                  gint32 access_mode, gint32 share, gint32 options,
175                                  gint32 *error);
176
177 extern MonoBoolean
178 ves_icall_System_IO_MonoIO_Close (HANDLE handle, gint32 *error);
179
180 extern gint32 
181 ves_icall_System_IO_MonoIO_Read (HANDLE handle, MonoArray *dest,
182                                  gint32 dest_offset, gint32 count,
183                                  gint32 *error);
184
185 extern gint32 
186 ves_icall_System_IO_MonoIO_Write (HANDLE handle, MonoArray *src,
187                                   gint32 src_offset, gint32 count,
188                                   gint32 *error);
189
190 extern gint64 
191 ves_icall_System_IO_MonoIO_Seek (HANDLE handle, gint64 offset, gint32 origin,
192                                  gint32 *error);
193
194 extern MonoBoolean
195 ves_icall_System_IO_MonoIO_Flush (HANDLE handle, gint32 *error);
196
197 extern gint64 
198 ves_icall_System_IO_MonoIO_GetLength (HANDLE handle, gint32 *error);
199
200 extern MonoBoolean
201 ves_icall_System_IO_MonoIO_SetLength (HANDLE handle, gint64 length,
202                                       gint32 *error);
203
204 extern MonoBoolean
205 ves_icall_System_IO_MonoIO_SetFileTime (HANDLE handle, gint64 creation_time,
206                                         gint64 last_access_time,
207                                         gint64 last_write_time, gint32 *error);
208
209 extern HANDLE 
210 ves_icall_System_IO_MonoIO_get_ConsoleOutput (void);
211
212 extern HANDLE 
213 ves_icall_System_IO_MonoIO_get_ConsoleInput (void);
214
215 extern HANDLE 
216 ves_icall_System_IO_MonoIO_get_ConsoleError (void);
217
218 extern MonoBoolean
219 ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle, HANDLE *write_handle, gint32 *error);
220
221 extern MonoBoolean
222 ves_icall_System_IO_MonoIO_DuplicateHandle (HANDLE source_process_handle, HANDLE source_handle,
223                 HANDLE target_process_handle, HANDLE *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error);
224
225 extern gunichar2 
226 ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar (void);
227
228 extern gunichar2 
229 ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar (void);
230
231 extern gunichar2 
232 ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar (void);
233
234 extern gunichar2 
235 ves_icall_System_IO_MonoIO_get_PathSeparator (void);
236
237 extern MonoArray *
238 ves_icall_System_IO_MonoIO_get_InvalidPathChars (void);
239
240 extern void ves_icall_System_IO_MonoIO_Lock (HANDLE handle, gint64 position,
241                                              gint64 length, gint32 *error);
242 extern void ves_icall_System_IO_MonoIO_Unlock (HANDLE handle, gint64 position,
243                                                gint64 length, gint32 *error);
244
245 extern MonoBoolean
246 ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString *destinationFileName,
247                                         MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors,
248                                         gint32 *error);
249
250 extern gint64
251 mono_filesize_from_path (MonoString *path);
252
253 extern gint64
254 mono_filesize_from_fd (int fd);
255
256 void
257 ves_icall_System_IO_MonoIO_DumpHandles (void);
258
259 G_END_DECLS
260
261 #endif /* _MONO_METADATA_FILEIO_H_ */