Merge pull request #4178 from ntherning/fix-broken-windows-build
[mono-project.git] / mono / metadata / file-io.h
blobb7b7320debbf641c1f9946a9bd3ec2b0e00025a0
1 /*
2 * file-io.h: File IO internal calls
4 * Authors:
5 * Dick Porter (dick@ximian.com)
6 * Dan Lewis (dihlewis@yahoo.co.uk)
8 * (C) 2001 Ximian, Inc.
9 * Copyright 2012 Xamarin Inc (http://www.xamarin.com)
10 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
13 #ifndef _MONO_METADATA_FILEIO_H_
14 #define _MONO_METADATA_FILEIO_H_
16 #include <config.h>
17 #include <glib.h>
19 #include <mono/metadata/object-internals.h>
20 #include <mono/utils/mono-compiler.h>
22 G_BEGIN_DECLS
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;
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;
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;
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;
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;
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;
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;
114 /* System.IO.MonoIO */
116 extern MonoBoolean
117 ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error);
119 extern MonoBoolean
120 ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error);
122 MonoArray *
123 ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *path,
124 MonoString *path_with_pattern,
125 gint mask, gint attrs,
126 gint32 *error);
128 extern gpointer
129 ves_icall_System_IO_MonoIO_FindFirstFile (MonoString *path_with_pattern,
130 MonoString **file_name,
131 gint32 *file_attr,
132 gint32 *ioerror);
134 extern MonoBoolean
135 ves_icall_System_IO_MonoIO_FindNextFile (gpointer hnd,
136 MonoString **file_name,
137 gint32 *file_attr,
138 gint32 *ioerror);
140 extern MonoBoolean
141 ves_icall_System_IO_MonoIO_FindCloseFile (gpointer hnd);
143 extern MonoString *
144 ves_icall_System_IO_MonoIO_FindFirst (MonoString *path,
145 MonoString *path_with_pattern,
146 gint32 *result_mask,
147 gint32 *error,
148 gpointer *handle);
149 extern MonoString *
150 ves_icall_System_IO_MonoIO_FindNext (gpointer handle, gint32 *result_mask, gint32 *error);
152 extern int
153 ves_icall_System_IO_MonoIO_FindClose (gpointer handle);
155 extern MonoString *
156 ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error);
158 extern MonoBoolean
159 ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
160 gint32 *error);
162 extern MonoBoolean
163 ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest,
164 gint32 *error);
166 extern MonoBoolean
167 ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
168 MonoBoolean overwrite, gint32 *error);
170 extern MonoBoolean
171 ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error);
173 extern gint32
174 ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error);
176 extern MonoBoolean
177 ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
178 gint32 *error);
180 extern gint32
181 ves_icall_System_IO_MonoIO_GetFileType (gpointer handle, gint32 *error);
183 extern MonoBoolean
184 ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat,
185 gint32 *error);
187 extern gpointer
188 ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
189 gint32 access_mode, gint32 share, gint32 options,
190 gint32 *error);
192 extern MonoBoolean
193 ves_icall_System_IO_MonoIO_Close (gpointer handle, gint32 *error);
195 extern gint32
196 ves_icall_System_IO_MonoIO_Read (gpointer handle, MonoArray *dest,
197 gint32 dest_offset, gint32 count,
198 gint32 *error);
200 extern gint32
201 ves_icall_System_IO_MonoIO_Write (gpointer handle, MonoArray *src,
202 gint32 src_offset, gint32 count,
203 gint32 *error);
205 extern gint64
206 ves_icall_System_IO_MonoIO_Seek (gpointer handle, gint64 offset, gint32 origin,
207 gint32 *error);
209 extern MonoBoolean
210 ves_icall_System_IO_MonoIO_Flush (gpointer handle, gint32 *error);
212 extern gint64
213 ves_icall_System_IO_MonoIO_GetLength (gpointer handle, gint32 *error);
215 extern MonoBoolean
216 ves_icall_System_IO_MonoIO_SetLength (gpointer handle, gint64 length,
217 gint32 *error);
219 extern MonoBoolean
220 ves_icall_System_IO_MonoIO_SetFileTime (gpointer handle, gint64 creation_time,
221 gint64 last_access_time,
222 gint64 last_write_time, gint32 *error);
224 extern gpointer
225 ves_icall_System_IO_MonoIO_get_ConsoleOutput (void);
227 extern gpointer
228 ves_icall_System_IO_MonoIO_get_ConsoleInput (void);
230 extern gpointer
231 ves_icall_System_IO_MonoIO_get_ConsoleError (void);
233 extern MonoBoolean
234 ves_icall_System_IO_MonoIO_CreatePipe (gpointer *read_handle, gpointer *write_handle, gint32 *error);
236 extern MonoBoolean
237 ves_icall_System_IO_MonoIO_DuplicateHandle (gpointer source_process_handle, gpointer source_handle,
238 gpointer target_process_handle, gpointer *target_handle, gint32 access, gint32 inherit, gint32 options, gint32 *error);
240 extern gunichar2
241 ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar (void);
243 extern gunichar2
244 ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar (void);
246 extern gunichar2
247 ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar (void);
249 extern gunichar2
250 ves_icall_System_IO_MonoIO_get_PathSeparator (void);
252 extern MonoArray *
253 ves_icall_System_IO_MonoIO_get_InvalidPathChars (void);
255 extern void ves_icall_System_IO_MonoIO_Lock (gpointer handle, gint64 position,
256 gint64 length, gint32 *error);
257 extern void ves_icall_System_IO_MonoIO_Unlock (gpointer handle, gint64 position,
258 gint64 length, gint32 *error);
260 extern MonoBoolean
261 ves_icall_System_IO_MonoIO_ReplaceFile (MonoString *sourceFileName, MonoString *destinationFileName,
262 MonoString *destinationBackupFileName, MonoBoolean ignoreMetadataErrors,
263 gint32 *error);
265 MONO_RT_EXTERNAL_ONLY
266 extern gint64
267 mono_filesize_from_path (MonoString *path);
269 extern gint64
270 mono_filesize_from_fd (int fd);
272 void
273 ves_icall_System_IO_MonoIO_DumpHandles (void);
275 G_END_DECLS
277 #endif /* _MONO_METADATA_FILEIO_H_ */