Don't keep main exe and dlls handles open when the file is on
[wine] / include / file.h
1 /*
2  * File handling declarations
3  *
4  * Copyright 1996 Alexandre Julliard
5  */
6
7 #ifndef __WINE_FILE_H
8 #define __WINE_FILE_H
9
10 #include <time.h> /* time_t */
11 #include <sys/time.h>
12 #include "winbase.h"
13 #include "wine/windef16.h"  /* HFILE16 */
14
15 #define MAX_PATHNAME_LEN   1024
16
17 /* Definition of a full DOS file name */
18 typedef struct
19 {
20     char  long_name[MAX_PATHNAME_LEN];  /* Long pathname in Unix format */
21     char  short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */
22     int   drive;
23 } DOS_FULL_NAME;
24
25 #define IS_END_OF_NAME(ch)  (!(ch) || ((ch) == '/') || ((ch) == '\\'))
26
27 /* DOS device descriptor */
28 typedef struct
29 {
30     char *name;
31     int flags;
32 } DOS_DEVICE;
33
34 /* overlapped private structure */
35 struct async_private;
36 typedef void (*async_handler)(struct async_private *ovp, int revents);
37 typedef struct async_private
38 {
39      LPOVERLAPPED  lpOverlapped;
40      int           fd;
41      int           timeout;
42      struct timeval tv;
43      int           event;
44      char         *buffer;
45      async_handler func;
46      int           count;
47      LPOVERLAPPED_COMPLETION_ROUTINE completion_func;
48      struct async_private *next;
49      struct async_private *prev;
50 } async_private;
51
52 /* locale-independent case conversion */
53 inline static char FILE_tolower( char c )
54 {
55     if (c >= 'A' && c <= 'Z') c += 32;
56     return c;
57 }
58 inline static char FILE_toupper( char c )
59 {
60     if (c >= 'a' && c <= 'z') c -= 32;
61     return c;
62 }
63
64 inline static int FILE_contains_path (LPCSTR name)
65 {
66     return ((*name && (name[1] == ':')) ||
67             strchr (name, '/') || strchr (name, '\\'));
68 }
69
70 /* files/file.c */
71 extern int FILE_strcasecmp( const char *str1, const char *str2 );
72 extern int FILE_strncasecmp( const char *str1, const char *str2, int len );
73 extern void FILE_SetDosError(void);
74 extern HANDLE FILE_DupUnixHandle( int fd, DWORD access );
75 extern int FILE_GetUnixHandle( HANDLE handle, DWORD access );
76 extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
77 extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 );
78 extern HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
79                                LPSECURITY_ATTRIBUTES sa, DWORD creation,
80                                DWORD attributes, HANDLE template, BOOL fail_read_only,
81                                UINT drive_type );
82 extern HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa );
83
84 extern LONG WINAPI WIN16_hread(HFILE16,SEGPTR,LONG);
85
86 /* files/directory.c */
87 extern int DIR_Init(void);
88 extern UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count );
89 extern UINT DIR_GetSystemUnixDir( LPSTR path, UINT count );
90 extern DWORD DIR_SearchAlternatePath( LPCSTR dll_path, LPCSTR name, LPCSTR ext,
91                                       DWORD buflen, LPSTR buffer, LPSTR *lastpart);
92 extern DWORD DIR_SearchPath( LPCSTR path, LPCSTR name, LPCSTR ext,
93                              DOS_FULL_NAME *full_name, BOOL win32 );
94
95 /* files/dos_fs.c */
96 extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft,
97                                       DWORD remainder );
98 extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
99 extern BOOL DOSFS_ToDosFCBFormat( LPCSTR name, LPSTR buffer );
100 extern const DOS_DEVICE *DOSFS_GetDevice( const char *name );
101 extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HFILE hFile );
102 extern HANDLE DOSFS_OpenDevice( const char *name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa);
103 extern BOOL DOSFS_FindUnixName( LPCSTR path, LPCSTR name, LPSTR long_buf,
104                                   INT long_len, LPSTR short_buf,
105                                   BOOL ignore_case );
106 extern BOOL DOSFS_GetFullName( LPCSTR name, BOOL 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_DATAA *entry );
111
112 /* win32/device.c */
113 extern HANDLE DEVICE_Open( LPCSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa );
114
115 #endif  /* __WINE_FILE_H */