New test.
[mono.git] / mono / io-layer / io.h
1 /*
2  * io.h: File, console and find handles
3  *
4  * Author:
5  *      Dick Porter (dick@ximian.com)
6  *
7  * (C) 2002 Ximian, Inc.
8  */
9
10 #ifndef _WAPI_IO_H_
11 #define _WAPI_IO_H_
12
13 #include <stdlib.h>
14
15 #include "mono/io-layer/wapi.h"
16 #include "mono/io-layer/timefuncs.h"
17
18 G_BEGIN_DECLS
19
20 typedef struct _WapiSecurityAttributes WapiSecurityAttributes;
21
22 struct _WapiSecurityAttributes 
23 {
24         guint32 nLength;
25         gpointer lpSecurityDescriptor;
26         gboolean bInheritHandle;
27 };
28
29 typedef struct _WapiOverlapped WapiOverlapped;
30
31 struct _WapiOverlapped
32 {
33         guint32 Internal;
34         guint32 InternalHigh;
35         guint32 Offset;
36         guint32 OffsetHigh;
37         gpointer hEvent;
38         gpointer handle1;
39         gpointer handle2;
40 };
41
42 typedef void (*WapiOverlappedCB) (guint32 error, guint32 numbytes,
43                                   WapiOverlapped *overlapped);
44
45 #define GENERIC_READ    0x80000000
46 #define GENERIC_WRITE   0x40000000
47 #define GENERIC_EXECUTE 0x20000000
48 #define GENERIC_ALL     0x10000000
49
50 #define FILE_SHARE_READ         0x00000001
51 #define FILE_SHARE_WRITE        0x00000002
52 #define FILE_SHARE_DELETE       0x00000004
53
54 #define CREATE_NEW              1
55 #define CREATE_ALWAYS           2
56 #define OPEN_EXISTING           3
57 #define OPEN_ALWAYS             4
58 #define TRUNCATE_EXISTING       5
59
60
61 #define FILE_ATTRIBUTE_READONLY                 0x00000001
62 #define FILE_ATTRIBUTE_HIDDEN                   0x00000002
63 #define FILE_ATTRIBUTE_SYSTEM                   0x00000004
64 #define FILE_ATTRIBUTE_DIRECTORY                0x00000010
65 #define FILE_ATTRIBUTE_ARCHIVE                  0x00000020
66 #define FILE_ATTRIBUTE_ENCRYPTED                0x00000040
67 #define FILE_ATTRIBUTE_NORMAL                   0x00000080
68 #define FILE_ATTRIBUTE_TEMPORARY                0x00000100
69 #define FILE_ATTRIBUTE_SPARSE_FILE              0x00000200
70 #define FILE_ATTRIBUTE_REPARSE_POINT            0x00000400
71 #define FILE_ATTRIBUTE_COMPRESSED               0x00000800
72 #define FILE_ATTRIBUTE_OFFLINE                  0x00001000
73 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED      0x00002000
74 #define FILE_FLAG_OPEN_NO_RECALL                0x00100000
75 #define FILE_FLAG_OPEN_REPARSE_POINT            0x00200000
76 #define FILE_FLAG_POSIX_SEMANTICS               0x01000000
77 #define FILE_FLAG_BACKUP_SEMANTICS              0x02000000
78 #define FILE_FLAG_DELETE_ON_CLOSE               0x04000000
79 #define FILE_FLAG_SEQUENTIAL_SCAN               0x08000000
80 #define FILE_FLAG_RANDOM_ACCESS                 0x10000000
81 #define FILE_FLAG_NO_BUFFERING                  0x20000000
82 #define FILE_FLAG_OVERLAPPED                    0x40000000
83 #define FILE_FLAG_WRITE_THROUGH                 0x80000000
84
85 #define MAX_PATH        260
86
87 typedef enum {
88         STD_INPUT_HANDLE=-10,
89         STD_OUTPUT_HANDLE=-11,
90         STD_ERROR_HANDLE=-12
91 } WapiStdHandle;
92
93 typedef enum {
94         FILE_BEGIN=0,
95         FILE_CURRENT=1,
96         FILE_END=2
97 } WapiSeekMethod;
98
99 typedef enum {
100         FILE_TYPE_UNKNOWN=0x0000,
101         FILE_TYPE_DISK=0x0001,
102         FILE_TYPE_CHAR=0x0002,
103         FILE_TYPE_PIPE=0x0003,
104         FILE_TYPE_REMOTE=0x8000
105 } WapiFileType;
106
107 typedef enum {
108         GetFileExInfoStandard=0x0000,
109         GetFileExMaxInfoLevel=0x0001
110 } WapiGetFileExInfoLevels;
111
112 typedef struct 
113 {
114         guint16 wYear;
115         guint16 wMonth;
116         guint16 wDayOfWeek;
117         guint16 wDay;
118         guint16 wHour;
119         guint16 wMinute;
120         guint16 wSecond;
121         guint16 wMilliseconds;
122 } WapiSystemTime;
123
124 typedef struct
125 {
126         guint32 dwFileAttributes;
127         WapiFileTime ftCreationTime;
128         WapiFileTime ftLastAccessTime;
129         WapiFileTime ftLastWriteTime;
130         guint32 nFileSizeHigh;
131         guint32 nFileSizeLow;
132         guint32 dwReserved0;
133         guint32 dwReserved1;
134         gunichar2 cFileName [MAX_PATH];
135         gunichar2 cAlternateFileName [14];
136 } WapiFindData;
137
138 typedef struct
139 {
140         guint32 dwFileAttributes;
141         WapiFileTime ftCreationTime;
142         WapiFileTime ftLastAccessTime;
143         WapiFileTime ftLastWriteTime;
144         guint32 nFileSizeHigh;
145         guint32 nFileSizeLow;
146 } WapiFileAttributesData;
147
148 #define INVALID_SET_FILE_POINTER ((guint32)-1)
149 #define INVALID_FILE_SIZE ((guint32)0xFFFFFFFF)
150 #define INVALID_FILE_ATTRIBUTES ((guint32)-1)
151
152 extern gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
153                            guint32 sharemode,
154                            WapiSecurityAttributes *security,
155                            guint32 createmode,
156                            guint32 attrs, gpointer tmplate);
157 extern gboolean DeleteFile(const gunichar2 *name);
158 extern gpointer GetStdHandle(WapiStdHandle stdhandle);
159 extern gboolean ReadFile(gpointer handle, gpointer buffer, guint32 numbytes,
160                          guint32 *bytesread, WapiOverlapped *overlapped);
161 extern gboolean WriteFile(gpointer handle, gconstpointer buffer,
162                           guint32 numbytes, guint32 *byteswritten,
163                           WapiOverlapped *overlapped);
164 extern gboolean FlushFileBuffers(gpointer handle);
165 extern gboolean SetEndOfFile(gpointer handle);
166 extern guint32 SetFilePointer(gpointer handle, gint32 movedistance,
167                               gint32 *highmovedistance, WapiSeekMethod method);
168 extern WapiFileType GetFileType(gpointer handle);
169 extern guint32 GetFileSize(gpointer handle, guint32 *highsize);
170 extern gboolean GetFileTime(gpointer handle, WapiFileTime *create_time,
171                             WapiFileTime *last_access,
172                             WapiFileTime *last_write);
173 extern gboolean SetFileTime(gpointer handle, const WapiFileTime *create_time,
174                             const WapiFileTime *last_access,
175                             const WapiFileTime *last_write);
176 extern gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
177                                      WapiSystemTime *system_time);
178 extern gpointer FindFirstFile (const gunichar2 *pattern,
179                                WapiFindData *find_data);
180 extern gboolean FindNextFile (gpointer handle, WapiFindData *find_data);
181 extern gboolean FindClose (gpointer handle);
182 extern gboolean CreateDirectory (const gunichar2 *name,
183                                  WapiSecurityAttributes *security);
184 extern gboolean RemoveDirectory (const gunichar2 *name);
185 extern gboolean MoveFile (const gunichar2 *name, const gunichar2 *dest_name);
186 extern gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
187                           gboolean fail_if_exists);
188 extern guint32 GetFileAttributes (const gunichar2 *name);
189 extern gboolean GetFileAttributesEx (const gunichar2 *name,
190                                      WapiGetFileExInfoLevels level,
191                                      gpointer info);
192 extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs);
193 extern guint32 GetCurrentDirectory (guint32 length, gunichar2 *buffer);
194 extern gboolean SetCurrentDirectory (const gunichar2 *path);
195 extern gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
196                             WapiSecurityAttributes *security, guint32 size);
197 extern guint32 GetTempPath (guint32 len, gunichar2 *buf);
198 extern gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf);
199 extern gboolean LockFile (gpointer handle, guint32 offset_low,
200                           guint32 offset_high, guint32 length_low,
201                           guint32 length_high);
202 extern gboolean UnlockFile (gpointer handle, guint32 offset_low,
203                             guint32 offset_high, guint32 length_low,
204                             guint32 length_high);
205
206 G_END_DECLS
207
208 #endif /* _WAPI_IO_H_ */