2005-05-26 Gonzalo Paniagua Javier <gonzalo@ximian.com>
[mono.git] / mono / io-layer / io.h
index b52e02e0ec4dc9294f7dc1249548cf1dac60f5dc..a9b68208f4d468c17694b6c078bc762f9c05d7ef 100644 (file)
@@ -1,9 +1,19 @@
+/*
+ * io.h: File, console and find handles
+ *
+ * Author:
+ *     Dick Porter (dick@ximian.com)
+ *
+ * (C) 2002 Ximian, Inc.
+ */
+
 #ifndef _WAPI_IO_H_
 #define _WAPI_IO_H_
 
 #include <stdlib.h>
 
 #include "mono/io-layer/wapi.h"
+#include "mono/io-layer/timefuncs.h"
 
 typedef struct _WapiSecurityAttributes WapiSecurityAttributes;
 
@@ -22,9 +32,14 @@ struct _WapiOverlapped
        guint32 InternalHigh;
        guint32 Offset;
        guint32 OffsetHigh;
-       WapiHandle *hEvent;
+       gpointer hEvent;
+       gpointer handle1;
+       gpointer handle2;
 };
 
+typedef void (*WapiOverlappedCB) (guint32 error, guint32 numbytes,
+                                 WapiOverlapped *overlapped);
+
 #define GENERIC_READ   0x80000000
 #define GENERIC_WRITE  0x40000000
 #define GENERIC_EXECUTE        0x20000000
@@ -65,16 +80,18 @@ struct _WapiOverlapped
 #define FILE_FLAG_OVERLAPPED                   0x40000000
 #define FILE_FLAG_WRITE_THROUGH                        0x80000000
 
+#define MAX_PATH       260
+
 typedef enum {
        STD_INPUT_HANDLE=-10,
        STD_OUTPUT_HANDLE=-11,
-       STD_ERROR_HANDLE=-12,
+       STD_ERROR_HANDLE=-12
 } WapiStdHandle;
 
 typedef enum {
        FILE_BEGIN=0,
        FILE_CURRENT=1,
-       FILE_END=2,
+       FILE_END=2
 } WapiSeekMethod;
 
 typedef enum {
@@ -82,14 +99,13 @@ typedef enum {
        FILE_TYPE_DISK=0x0001,
        FILE_TYPE_CHAR=0x0002,
        FILE_TYPE_PIPE=0x0003,
-       FILE_TYPE_REMOTE=0x8000,
+       FILE_TYPE_REMOTE=0x8000
 } WapiFileType;
 
-typedef struct 
-{
-       guint32 dwLowDateTime;
-       guint32 dwHighDateTime;
-} WapiFileTime;
+typedef enum {
+       GetFileExInfoStandard=0x0000,
+       GetFileExMaxInfoLevel=0x0001
+} WapiGetFileExInfoLevels;
 
 typedef struct 
 {
@@ -103,28 +119,86 @@ typedef struct
        guint16 wMilliseconds;
 } WapiSystemTime;
 
+typedef struct
+{
+       guint32 dwFileAttributes;
+       WapiFileTime ftCreationTime;
+       WapiFileTime ftLastAccessTime;
+       WapiFileTime ftLastWriteTime;
+       guint32 nFileSizeHigh;
+       guint32 nFileSizeLow;
+       guint32 dwReserved0;
+       guint32 dwReserved1;
+       gunichar2 cFileName [MAX_PATH];
+       gunichar2 cAlternateFileName [14];
+} WapiFindData;
+
+typedef struct
+{
+       guint32 dwFileAttributes;
+       WapiFileTime ftCreationTime;
+       WapiFileTime ftLastAccessTime;
+       WapiFileTime ftLastWriteTime;
+       guint32 nFileSizeHigh;
+       guint32 nFileSizeLow;
+} WapiFileAttributesData;
+
 #define INVALID_SET_FILE_POINTER ((guint32)-1)
 #define INVALID_FILE_SIZE ((guint32)0xFFFFFFFF)
-
-extern WapiHandle *CreateFile(const guchar *name, guint32 fileaccess,
-                             guint32 sharemode,
-                             WapiSecurityAttributes *security,
-                             guint32 createmode,
-                             guint32 attrs, WapiHandle *template);
-extern gboolean DeleteFile(const guchar *name);
-extern WapiHandle *GetStdHandle(WapiStdHandle stdhandle);
-extern gboolean ReadFile(WapiHandle *handle, gpointer buffer, guint32 numbytes,
+#define INVALID_FILE_ATTRIBUTES ((guint32)-1)
+
+extern gpointer CreateFile(const gunichar2 *name, guint32 fileaccess,
+                          guint32 sharemode,
+                          WapiSecurityAttributes *security,
+                          guint32 createmode,
+                          guint32 attrs, gpointer tmplate);
+extern gboolean DeleteFile(const gunichar2 *name);
+extern gpointer GetStdHandle(WapiStdHandle stdhandle);
+extern gboolean ReadFile(gpointer handle, gpointer buffer, guint32 numbytes,
                         guint32 *bytesread, WapiOverlapped *overlapped);
-extern gboolean WriteFile(WapiHandle *handle, gconstpointer buffer,
+extern gboolean WriteFile(gpointer handle, gconstpointer buffer,
                          guint32 numbytes, guint32 *byteswritten,
                          WapiOverlapped *overlapped);
-extern gboolean SetEndOfFile(WapiHandle *handle);
-extern guint32 SetFilePointer(WapiHandle *handle, gint32 movedistance,
+extern gboolean FlushFileBuffers(gpointer handle);
+extern gboolean SetEndOfFile(gpointer handle);
+extern guint32 SetFilePointer(gpointer handle, gint32 movedistance,
                              gint32 *highmovedistance, WapiSeekMethod method);
-extern WapiFileType GetFileType(WapiHandle *handle);
-extern guint32 GetFileSize(WapiHandle *handle, guint32 *highsize);
-extern gboolean GetFileTime(WapiHandle *handle, WapiFileTime *create_time, WapiFileTime *last_access, WapiFileTime *last_write);
-extern gboolean SetFileTime(WapiHandle *handle, const WapiFileTime *create_time, const WapiFileTime *last_access, const WapiFileTime *last_write);
-extern gboolean FileTimeToSystemTime(const WapiFileTime *file_time, WapiSystemTime *system_time);
+extern WapiFileType GetFileType(gpointer handle);
+extern guint32 GetFileSize(gpointer handle, guint32 *highsize);
+extern gboolean GetFileTime(gpointer handle, WapiFileTime *create_time,
+                           WapiFileTime *last_access,
+                           WapiFileTime *last_write);
+extern gboolean SetFileTime(gpointer handle, const WapiFileTime *create_time,
+                           const WapiFileTime *last_access,
+                           const WapiFileTime *last_write);
+extern gboolean FileTimeToSystemTime(const WapiFileTime *file_time,
+                                    WapiSystemTime *system_time);
+extern gpointer FindFirstFile (const gunichar2 *pattern,
+                              WapiFindData *find_data);
+extern gboolean FindNextFile (gpointer handle, WapiFindData *find_data);
+extern gboolean FindClose (gpointer handle);
+extern gboolean CreateDirectory (const gunichar2 *name,
+                                WapiSecurityAttributes *security);
+extern gboolean RemoveDirectory (const gunichar2 *name);
+extern gboolean MoveFile (const gunichar2 *name, const gunichar2 *dest_name);
+extern gboolean CopyFile (const gunichar2 *name, const gunichar2 *dest_name,
+                         gboolean fail_if_exists);
+extern guint32 GetFileAttributes (const gunichar2 *name);
+extern gboolean GetFileAttributesEx (const gunichar2 *name,
+                                    WapiGetFileExInfoLevels level,
+                                    gpointer info);
+extern gboolean SetFileAttributes (const gunichar2 *name, guint32 attrs);
+extern guint32 GetCurrentDirectory (guint32 length, gunichar2 *buffer);
+extern gboolean SetCurrentDirectory (const gunichar2 *path);
+extern gboolean CreatePipe (gpointer *readpipe, gpointer *writepipe,
+                           WapiSecurityAttributes *security, guint32 size);
+extern guint32 GetTempPath (guint32 len, gunichar2 *buf);
+extern gint32 GetLogicalDriveStrings (guint32 len, gunichar2 *buf);
+extern gboolean LockFile (gpointer handle, guint32 offset_low,
+                         guint32 offset_high, guint32 length_low,
+                         guint32 length_high);
+extern gboolean UnlockFile (gpointer handle, guint32 offset_low,
+                           guint32 offset_high, guint32 length_low,
+                           guint32 length_high);
 
 #endif /* _WAPI_IO_H_ */