2005-12-23 Dick Porter <dick@ximian.com>
[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  */
10
11 #ifndef _MONO_METADATA_FILEIO_H_
12 #define _MONO_METADATA_FILEIO_H_
13
14 #include <config.h>
15 #include <glib.h>
16
17 #include <mono/metadata/object-internals.h>
18 #include <mono/io-layer/io-layer.h>
19
20 G_BEGIN_DECLS
21
22 /* This is a copy of System.IO.FileAccess */
23 typedef enum {
24         FileAccess_Read=0x01,
25         FileAccess_Write=0x02,
26         FileAccess_ReadWrite=FileAccess_Read|FileAccess_Write
27 } MonoFileAccess;
28
29 /* This is a copy of System.IO.FileMode */
30 typedef enum {
31         FileMode_CreateNew=1,
32         FileMode_Create=2,
33         FileMode_Open=3,
34         FileMode_OpenOrCreate=4,
35         FileMode_Truncate=5,
36         FileMode_Append=6
37 } MonoFileMode;
38
39 /* This is a copy of System.IO.FileShare */
40 typedef enum {
41         FileShare_None=0x0,
42         FileShare_Read=0x01,
43         FileShare_Write=0x02,
44         FileShare_ReadWrite=FileShare_Read|FileShare_Write
45 } MonoFileShare;
46
47 /* This is a copy of System.IO.SeekOrigin */
48 typedef enum {
49         SeekOrigin_Begin=0,
50         SeekOrigin_Current=1,
51         SeekOrigin_End=2
52 } MonoSeekOrigin;
53
54 /* This is a copy of System.IO.MonoIOStat */
55 typedef struct _MonoIOStat {
56         MonoString *name;
57         gint32 attributes;
58         gint64 length;
59         gint64 creation_time;
60         gint64 last_access_time;
61         gint64 last_write_time;
62 } MonoIOStat;
63
64 /* This is a copy of System.IO.FileAttributes */
65 typedef enum {
66         FileAttributes_ReadOnly=0x00001,
67         FileAttributes_Hidden=0x00002,
68         FileAttributes_System=0x00004,
69         FileAttributes_Directory=0x00010,
70         FileAttributes_Archive=0x00020,
71         FileAttributes_Device=0x00040,
72         FileAttributes_Normal=0x00080,
73         FileAttributes_Temporary=0x00100,
74         FileAttributes_SparseFile=0x00200,
75         FileAttributes_ReparsePoint=0x00400,
76         FileAttributes_Compressed=0x00800,
77         FileAttributes_Offline=0x01000,
78         FileAttributes_NotContentIndexed=0x02000,
79         FileAttributes_Encrypted=0x04000,
80         FileAttributes_MonoExecutable= (int) 0x80000000
81 } MonoFileAttributes;
82
83 typedef struct _MonoFSAsyncResult {
84         MonoObject obj;
85         MonoObject *state;
86         MonoBoolean completed;
87         MonoBoolean done;
88         MonoException *exc;
89         MonoWaitHandle *wait_handle;
90         MonoDelegate *async_callback;
91         MonoBoolean completed_synch;
92         MonoArray *buffer;
93         gint offset;
94         gint count;
95         gint original_count;
96         gint bytes_read;
97         MonoDelegate *real_cb;
98 } MonoFSAsyncResult;
99
100 /* System.IO.MonoIO */
101
102 extern MonoBoolean
103 ves_icall_System_IO_MonoIO_CreateDirectory (MonoString *path, gint32 *error);
104
105 extern MonoBoolean
106 ves_icall_System_IO_MonoIO_RemoveDirectory (MonoString *path, gint32 *error);
107
108 MonoArray *
109 ves_icall_System_IO_MonoIO_GetFileSystemEntries (MonoString *_path, MonoString *_pattern,
110                                         gint mask, gint attrs, gint32 *error);
111
112 extern MonoString *
113 ves_icall_System_IO_MonoIO_GetCurrentDirectory (gint32 *error);
114
115 extern MonoBoolean
116 ves_icall_System_IO_MonoIO_SetCurrentDirectory (MonoString *path,
117                                                 gint32 *error);
118
119 extern MonoBoolean
120 ves_icall_System_IO_MonoIO_MoveFile (MonoString *path, MonoString *dest,
121                                      gint32 *error);
122
123 extern MonoBoolean
124 ves_icall_System_IO_MonoIO_CopyFile (MonoString *path, MonoString *dest,
125                                      MonoBoolean overwrite, gint32 *error);
126
127 extern MonoBoolean
128 ves_icall_System_IO_MonoIO_DeleteFile (MonoString *path, gint32 *error);
129
130 extern gint32 
131 ves_icall_System_IO_MonoIO_GetFileAttributes (MonoString *path, gint32 *error);
132
133 extern MonoBoolean
134 ves_icall_System_IO_MonoIO_SetFileAttributes (MonoString *path, gint32 attrs,
135                                               gint32 *error);
136
137 extern gint32
138 ves_icall_System_IO_MonoIO_GetFileType (HANDLE handle, gint32 *error);
139
140 extern MonoBoolean
141 ves_icall_System_IO_MonoIO_GetFileStat (MonoString *path, MonoIOStat *stat,
142                                         gint32 *error);
143
144 extern HANDLE 
145 ves_icall_System_IO_MonoIO_Open (MonoString *filename, gint32 mode,
146                                  gint32 access_mode, gint32 share,
147                                  MonoBoolean async, gint32 *error);
148
149 extern MonoBoolean
150 ves_icall_System_IO_MonoIO_Close (HANDLE handle, gint32 *error);
151
152 extern gint32 
153 ves_icall_System_IO_MonoIO_Read (HANDLE handle, MonoArray *dest,
154                                  gint32 dest_offset, gint32 count,
155                                  gint32 *error);
156
157 extern gint32 
158 ves_icall_System_IO_MonoIO_Write (HANDLE handle, MonoArray *src,
159                                   gint32 src_offset, gint32 count,
160                                   gint32 *error);
161
162 extern gint64 
163 ves_icall_System_IO_MonoIO_Seek (HANDLE handle, gint64 offset, gint32 origin,
164                                  gint32 *error);
165
166 extern MonoBoolean
167 ves_icall_System_IO_MonoIO_Flush (HANDLE handle, gint32 *error);
168
169 extern gint64 
170 ves_icall_System_IO_MonoIO_GetLength (HANDLE handle, gint32 *error);
171
172 extern MonoBoolean
173 ves_icall_System_IO_MonoIO_SetLength (HANDLE handle, gint64 length,
174                                       gint32 *error);
175
176 extern MonoBoolean
177 ves_icall_System_IO_MonoIO_SetFileTime (HANDLE handle, gint64 creation_time,
178                                         gint64 last_access_time,
179                                         gint64 last_write_time, gint32 *error);
180
181 extern HANDLE 
182 ves_icall_System_IO_MonoIO_get_ConsoleOutput (void);
183
184 extern HANDLE 
185 ves_icall_System_IO_MonoIO_get_ConsoleInput (void);
186
187 extern HANDLE 
188 ves_icall_System_IO_MonoIO_get_ConsoleError (void);
189
190 extern MonoBoolean
191 ves_icall_System_IO_MonoIO_CreatePipe (HANDLE *read_handle,
192                                        HANDLE *write_handle);
193
194 extern gunichar2 
195 ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar (void);
196
197 extern gunichar2 
198 ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar (void);
199
200 extern gunichar2 
201 ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar (void);
202
203 extern gunichar2 
204 ves_icall_System_IO_MonoIO_get_PathSeparator (void);
205
206 extern MonoArray *
207 ves_icall_System_IO_MonoIO_get_InvalidPathChars (void);
208
209 extern gint32
210 ves_icall_System_IO_MonoIO_GetTempPath (MonoString **mono_name);
211
212 extern void ves_icall_System_IO_MonoIO_Lock (HANDLE handle, gint64 position,
213                                              gint64 length, gint32 *error);
214 extern void ves_icall_System_IO_MonoIO_Unlock (HANDLE handle, gint64 position,
215                                                gint64 length, gint32 *error);
216
217 G_END_DECLS
218
219 #endif /* _MONO_METADATA_FILEIO_H_ */