Added beginnings of server-side file handling.
[wine/multimedia.git] / include / file.h
blobb70ae647058aab13c49ee41d609493aa77ce3aa6
1 /*
2 * File handling declarations
4 * Copyright 1996 Alexandre Julliard
5 */
7 #ifndef __WINE_FILE_H
8 #define __WINE_FILE_H
10 #include <time.h>
11 #include "windows.h"
12 #include "k32obj.h"
13 #include "thread.h"
15 #define MAX_PATHNAME_LEN 1024
17 /* The file object */
18 typedef struct
20 K32OBJ header;
21 int unix_handle;
22 int mode;
23 char *unix_name;
24 DWORD type; /* Type for win32 apps */
25 DWORD pos; /* workaround to emulate weird DOS error handling */
27 THREAD_QUEUE wait_queue;
28 } FILE_OBJECT;
30 /* Definition of a full DOS file name */
31 typedef struct
33 char long_name[MAX_PATHNAME_LEN]; /* Long pathname in Unix format */
34 char short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */
35 int drive;
36 } DOS_FULL_NAME;
38 #define IS_END_OF_NAME(ch) (!(ch) || ((ch) == '/') || ((ch) == '\\'))
40 /* DOS device descriptor */
41 typedef struct
43 char *name;
44 int flags;
45 } DOS_DEVICE;
47 /* Macros to convert 16 bit to 32 bit file handles and back */
48 /* LZW handles are exempt as if not, could go below 0x400 */
49 #define HFILE16_TO_HFILE32(handle) \
50 (((handle)==0) ? GetStdHandle(STD_INPUT_HANDLE) : \
51 ((handle)==1) ? GetStdHandle(STD_OUTPUT_HANDLE) : \
52 ((handle)==2) ? GetStdHandle(STD_ERROR_HANDLE) : \
53 ((handle)==3) ? GetStdHandle(STD_ERROR_HANDLE) : \
54 ((handle)==4) ? GetStdHandle(STD_ERROR_HANDLE) : \
55 ((handle)>=0x400) ? handle : \
56 (handle)-5)
58 #define HFILE32_TO_HFILE16(handle) ({ HFILE32 hnd=handle; \
59 ((hnd==HFILE_ERROR32) ? HFILE_ERROR16 : \
60 ((hnd)>=0x400) ? hnd : \
61 (HFILE16)hnd+5); })
64 /* files/file.c */
65 extern FILE_OBJECT *FILE_GetFile( HFILE32 handle, DWORD access,
66 int *server_handle );
67 extern void FILE_ReleaseFile( FILE_OBJECT *file );
68 extern HFILE32 FILE_Alloc( FILE_OBJECT **file, int unix_handle );
69 extern void FILE_SetDosError(void);
70 extern int FILE_GetUnixHandle( HFILE32 hFile, DWORD access );
71 extern HFILE32 FILE_DupUnixHandle( int fd );
72 extern BOOL32 FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
73 extern HFILE32 FILE_Dup( HFILE32 hFile );
74 extern HFILE32 FILE_Dup2( HFILE32 hFile1, HFILE32 hFile2 );
75 extern HFILE32 FILE_Open( LPCSTR path, INT32 mode ,INT32 sharemode);
76 extern HFILE32 FILE_OpenUnixFile( LPCSTR path, INT32 mode );
77 extern BOOL32 FILE_SetFileType( HFILE32 hFile, DWORD type );
78 extern LPVOID FILE_mmap( HFILE32 hFile, LPVOID start,
79 DWORD size_high, DWORD size_low,
80 DWORD offset_high, DWORD offset_low,
81 int prot, int flags );
82 extern LPVOID FILE_dommap( FILE_OBJECT *file, int unix_handle, LPVOID start,
83 DWORD size_high, DWORD size_low,
84 DWORD offset_high, DWORD offset_low,
85 int prot, int flags );
86 extern int FILE_munmap( LPVOID start, DWORD size_high, DWORD size_low );
87 extern HFILE32 _lcreat_uniq( LPCSTR path, INT32 attr );
89 /* files/directory.c */
90 extern int DIR_Init(void);
91 extern UINT32 DIR_GetWindowsUnixDir( LPSTR path, UINT32 count );
92 extern UINT32 DIR_GetSystemUnixDir( LPSTR path, UINT32 count );
93 extern DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
94 DOS_FULL_NAME *full_name, BOOL32 win32 );
96 /* files/dos_fs.c */
97 extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft,
98 DWORD remainder );
99 extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
100 extern BOOL32 DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer );
101 extern const DOS_DEVICE *DOSFS_GetDevice( const char *name );
102 extern HFILE32 DOSFS_OpenDevice( const char *name, INT32 mode );
103 extern BOOL32 DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf,
104 INT32 long_len, LPSTR short_buf,
105 BOOL32 ignore_case );
106 extern BOOL32 DOSFS_GetFullName( LPCSTR name, BOOL32 check_last,
107 DOS_FULL_NAME *full );
108 extern int DOSFS_FindNext( const char *path, const char *short_mask,
109 const char *long_mask, int drive, BYTE attr,
110 int skip, WIN32_FIND_DATA32A *entry );
112 #endif /* __WINE_FILE_H */