Convert most of the file APIs to Unicode.
[wine] / include / file.h
1 /*
2  * File handling declarations
3  *
4  * Copyright 1996 Alexandre Julliard
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef __WINE_FILE_H
22 #define __WINE_FILE_H
23
24 #include <time.h> /* time_t */
25 #include <sys/time.h>
26 #include <sys/types.h>
27 #include "winbase.h"
28 #include "wine/windef16.h"  /* HFILE16 */
29 #include "wine/unicode.h"
30
31 #define MAX_PATHNAME_LEN   1024
32
33 /* Definition of a full DOS file name */
34 typedef struct
35 {
36     char  long_name[MAX_PATHNAME_LEN];  /* Long pathname in Unix format */
37     WCHAR short_name[MAX_PATHNAME_LEN]; /* Short pathname in DOS 8.3 format */
38     int   drive;
39 } DOS_FULL_NAME;
40
41 #define IS_END_OF_NAME(ch)  (!(ch) || ((ch) == '/') || ((ch) == '\\'))
42
43 /* DOS device descriptor */
44 typedef struct
45 {
46     const WCHAR name[9];
47     int flags;
48     UINT codepage;
49 } DOS_DEVICE;
50
51 /* locale-independent case conversion */
52 inline static char FILE_tolower( char c )
53 {
54     if (c >= 'A' && c <= 'Z') c += 32;
55     return c;
56 }
57 inline static char FILE_toupper( char c )
58 {
59     if (c >= 'a' && c <= 'z') c -= 32;
60     return c;
61 }
62
63 inline static int FILE_contains_path (LPCSTR name)
64 {
65     return ((*name && (name[1] == ':')) ||
66             strchr (name, '/') || strchr (name, '\\'));
67 }
68
69 inline static int FILE_contains_pathW (LPCWSTR name)
70 {
71     return ((*name && (name[1] == ':')) ||
72             strchrW (name, '/') || strchrW (name, '\\'));
73 }
74
75 /* files/file.c */
76 extern mode_t FILE_umask;
77 extern int FILE_strcasecmp( const char *str1, const char *str2 );
78 extern int FILE_strncasecmp( const char *str1, const char *str2, int len );
79 extern void FILE_SetDosError(void);
80 extern int FILE_GetUnixHandle( HANDLE handle, DWORD access );
81 extern BOOL FILE_Stat( LPCSTR unixName, BY_HANDLE_FILE_INFORMATION *info );
82 extern HFILE16 FILE_Dup2( HFILE16 hFile1, HFILE16 hFile2 );
83 extern HANDLE FILE_CreateFile( LPCSTR filename, DWORD access, DWORD sharing,
84                                LPSECURITY_ATTRIBUTES sa, DWORD creation,
85                                DWORD attributes, HANDLE template, BOOL fail_read_only,
86                                UINT drive_type );
87 extern HANDLE FILE_CreateDevice( int client_id, DWORD access, LPSECURITY_ATTRIBUTES sa );
88
89 extern LONG WINAPI WIN16_hread(HFILE16,SEGPTR,LONG);
90
91 /* files/directory.c */
92 extern int DIR_Init(void);
93 extern UINT DIR_GetWindowsUnixDir( LPSTR path, UINT count );
94 extern UINT DIR_GetSystemUnixDir( LPSTR path, UINT count );
95 extern DWORD DIR_SearchAlternatePath( LPCSTR dll_path, LPCSTR name, LPCSTR ext,
96                                       DWORD buflen, LPSTR buffer, LPSTR *lastpart);
97 extern DWORD DIR_SearchPath( LPCWSTR path, LPCWSTR name, LPCWSTR ext,
98                              DOS_FULL_NAME *full_name, BOOL win32 );
99
100 /* files/dos_fs.c */
101 extern void DOSFS_UnixTimeToFileTime( time_t unixtime, LPFILETIME ft,
102                                       DWORD remainder );
103 extern time_t DOSFS_FileTimeToUnixTime( const FILETIME *ft, DWORD *remainder );
104 extern BOOL DOSFS_ToDosFCBFormat( LPCWSTR name, LPWSTR buffer );
105 extern const DOS_DEVICE *DOSFS_GetDevice( LPCWSTR name );
106 extern const DOS_DEVICE *DOSFS_GetDeviceByHandle( HANDLE hFile );
107 extern HANDLE DOSFS_OpenDevice( LPCWSTR name, DWORD access, DWORD attributes, LPSECURITY_ATTRIBUTES sa);
108 extern BOOL DOSFS_FindUnixName( const DOS_FULL_NAME *path, LPCWSTR name, char *long_buf,
109                                 INT long_len, LPWSTR short_buf, BOOL ignore_case );
110 extern BOOL DOSFS_GetFullName( LPCWSTR name, BOOL check_last,
111                                  DOS_FULL_NAME *full );
112 extern int DOSFS_FindNext( const char *path, const char *short_mask,
113                            const char *long_mask, int drive, BYTE attr,
114                            int skip, WIN32_FIND_DATAA *entry );
115
116 /* profile.c */
117 extern int PROFILE_LoadWineIni(void);
118 extern void PROFILE_UsageWineIni(void);
119 extern int PROFILE_GetWineIniString( LPCWSTR section, LPCWSTR key_name,
120                                      LPCWSTR def, LPWSTR buffer, int len );
121 extern int PROFILE_GetWineIniBool( LPCWSTR section, LPCWSTR key_name, int def );
122
123 /* win32/device.c */
124 extern HANDLE DEVICE_Open( LPCWSTR filename, DWORD access, LPSECURITY_ATTRIBUTES sa );
125
126 /* ntdll/cdrom.c.c */
127 extern BOOL CDROM_DeviceIoControl(DWORD clientID, HANDLE hDevice, DWORD dwIoControlCode,
128                                   LPVOID lpInBuffer, DWORD nInBufferSize,
129                                   LPVOID lpOutBuffer, DWORD nOutBufferSize,
130                                   LPDWORD lpBytesReturned, LPOVERLAPPED lpOverlapped);
131
132 #endif  /* __WINE_FILE_H */