1 | /* $Id: Fileio.cpp,v 1.5 1999-06-10 20:47:58 phaller Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | *
|
---|
5 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
6 | *
|
---|
7 | */
|
---|
8 | /*
|
---|
9 | * Win32 File IO API functions for OS/2
|
---|
10 | *
|
---|
11 | * Copyright 1998 Sander van Leeuwen
|
---|
12 | * Copyright 1998 Patrick Haller
|
---|
13 | *
|
---|
14 | */
|
---|
15 | #include <os2win.h>
|
---|
16 | #include <stdlib.h>
|
---|
17 | #include <string.h>
|
---|
18 | #include "unicode.h"
|
---|
19 | #include "handlemanager.h"
|
---|
20 | #include "devio.h"
|
---|
21 |
|
---|
22 | //******************************************************************************
|
---|
23 | //******************************************************************************
|
---|
24 | HFILE WIN32API CreateFileA(LPCSTR lpszName,
|
---|
25 | DWORD fdwAccess,
|
---|
26 | DWORD fdwShareMode,
|
---|
27 | LPSECURITY_ATTRIBUTES lpsa,
|
---|
28 | DWORD fdwCreate,
|
---|
29 | DWORD fdwAttrsAndFlags,
|
---|
30 | HANDLE hTemplateFile)
|
---|
31 | {
|
---|
32 | HANDLE rc;
|
---|
33 | HANDLE hFile;
|
---|
34 |
|
---|
35 | if(lpszName == NULL)
|
---|
36 | return(NULL);
|
---|
37 |
|
---|
38 | dprintf(("KERNEL32: CreateFile %s\n", lpszName));
|
---|
39 |
|
---|
40 | if(strncmp(lpszName,
|
---|
41 | "\\\\.\\",
|
---|
42 | 4) == 0)
|
---|
43 | {
|
---|
44 | return(OS2CreateFile((char *)&lpszName[4],
|
---|
45 | fdwAccess,
|
---|
46 | fdwShareMode));
|
---|
47 | }
|
---|
48 |
|
---|
49 | dprintf(("KERNEL32: CreateFileA(%s,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
---|
50 | lpszName,
|
---|
51 | fdwAccess,
|
---|
52 | fdwShareMode,
|
---|
53 | lpsa,
|
---|
54 | fdwCreate,
|
---|
55 | fdwAttrsAndFlags,
|
---|
56 | hTemplateFile));
|
---|
57 |
|
---|
58 | rc = O32_CreateFile(lpszName,
|
---|
59 | fdwAccess,
|
---|
60 | fdwShareMode,
|
---|
61 | lpsa,
|
---|
62 | fdwCreate,
|
---|
63 | fdwAttrsAndFlags,
|
---|
64 | hTemplateFile);
|
---|
65 |
|
---|
66 | /* @@@PH 1998/02/12 Handle Manager support */
|
---|
67 | if (rc == -1)
|
---|
68 | rc = HMCreateFile(lpszName,
|
---|
69 | fdwAccess,
|
---|
70 | fdwShareMode,
|
---|
71 | lpsa,
|
---|
72 | fdwCreate,
|
---|
73 | fdwAttrsAndFlags,
|
---|
74 | hTemplateFile);
|
---|
75 |
|
---|
76 | /* @@@PH experimental Handlemanager support */
|
---|
77 | if (HMHandleAllocate(&hFile,
|
---|
78 | rc) == NO_ERROR)
|
---|
79 | rc = hFile;
|
---|
80 |
|
---|
81 | dprintf(("KERNEL32: CreateFile returned %08xh\n",
|
---|
82 | rc));
|
---|
83 |
|
---|
84 | return(rc);
|
---|
85 | }
|
---|
86 | //******************************************************************************
|
---|
87 | //******************************************************************************
|
---|
88 | HFILE WIN32API CreateFileW(LPCWSTR arg1,
|
---|
89 | DWORD arg2,
|
---|
90 | DWORD arg3,
|
---|
91 | PSECURITY_ATTRIBUTES arg4,
|
---|
92 | DWORD arg5,
|
---|
93 | DWORD arg6,
|
---|
94 | HANDLE arg7)
|
---|
95 | {
|
---|
96 | HANDLE rc;
|
---|
97 | char *astring;
|
---|
98 |
|
---|
99 | dprintf(("KERNEL32: CreateFileW"));
|
---|
100 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
101 | rc = CreateFileA(astring, arg2, arg3, arg4, arg5, arg6, arg7);
|
---|
102 | FreeAsciiString(astring);
|
---|
103 | return(rc);
|
---|
104 | }
|
---|
105 | //******************************************************************************
|
---|
106 | //******************************************************************************
|
---|
107 | HANDLE WIN32API FindFirstFileA(LPCSTR arg1, WIN32_FIND_DATAA * arg2)
|
---|
108 | {
|
---|
109 | dprintf(("KERNEL32: FindFirstFile %s\n", arg1));
|
---|
110 |
|
---|
111 | return O32_FindFirstFile(arg1, arg2);
|
---|
112 | }
|
---|
113 | //******************************************************************************
|
---|
114 | //******************************************************************************
|
---|
115 | HANDLE WIN32API FindFirstFileW(LPCWSTR arg1, WIN32_FIND_DATAW * arg2)
|
---|
116 | {
|
---|
117 | HANDLE rc;
|
---|
118 | char *astring;
|
---|
119 |
|
---|
120 | dprintf(("KERNEL32: FindFirstFileW: not implemented!!"));
|
---|
121 |
|
---|
122 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
123 | // rc = O32_FindFirstFile(astring, arg2);
|
---|
124 | rc = 0;
|
---|
125 | FreeAsciiString(astring);
|
---|
126 | return(rc);
|
---|
127 | }
|
---|
128 | //******************************************************************************
|
---|
129 | //******************************************************************************
|
---|
130 | BOOL WIN32API FindNextFileA(HANDLE arg1, WIN32_FIND_DATAA * arg2)
|
---|
131 | {
|
---|
132 | dprintf(("KERNEL32: FindNextFile"));
|
---|
133 | return O32_FindNextFile(arg1, arg2);
|
---|
134 | }
|
---|
135 | //******************************************************************************
|
---|
136 | //TODO: convert string in WIN32_FIND_DATAW * structure
|
---|
137 | //******************************************************************************
|
---|
138 | BOOL WIN32API FindNextFileW(HANDLE arg1, WIN32_FIND_DATAW * arg2)
|
---|
139 | {
|
---|
140 | dprintf(("KERNEL32: FindNextFileW Not properly implemented!\n"));
|
---|
141 | // return O32_FindNextFile(arg1, arg2);
|
---|
142 | return 0;
|
---|
143 | }
|
---|
144 | //******************************************************************************
|
---|
145 | //******************************************************************************
|
---|
146 | BOOL WIN32API FindClose(HANDLE arg1)
|
---|
147 | {
|
---|
148 | dprintf(("KERNEL32: FindClose\n"));
|
---|
149 | return O32_FindClose(arg1);
|
---|
150 | }
|
---|
151 | //******************************************************************************
|
---|
152 | //******************************************************************************
|
---|
153 | DWORD WIN32API GetFileType(HANDLE file)
|
---|
154 | {
|
---|
155 | DWORD rc;
|
---|
156 | HFILE hFile;
|
---|
157 |
|
---|
158 | /* @@@PH 1998/02/12 Handle Manager support */
|
---|
159 | if (IS_HM_HANDLE(file))
|
---|
160 | return (HMGetFileType(file));
|
---|
161 |
|
---|
162 | /* @@@PH experimental Handlemanager support */
|
---|
163 | if (HMHandleTranslateToOS2(file,
|
---|
164 | &hFile) == NO_ERROR)
|
---|
165 | file = hFile;
|
---|
166 |
|
---|
167 | dprintf(("KERNEL32: GetFileType %08xh\n",
|
---|
168 | file));
|
---|
169 |
|
---|
170 | rc = O32_GetFileType(file);
|
---|
171 | if(rc == 0)
|
---|
172 | {
|
---|
173 | //bugfix
|
---|
174 | rc = 1;
|
---|
175 | }
|
---|
176 |
|
---|
177 | dprintf(("KERNEL32: GetFileType returned %08xh\n",
|
---|
178 | rc));
|
---|
179 |
|
---|
180 | return(rc);
|
---|
181 | }
|
---|
182 | //******************************************************************************
|
---|
183 | //******************************************************************************
|
---|
184 | DWORD WIN32API GetFileInformationByHandle(HANDLE arg1,
|
---|
185 | BY_HANDLE_FILE_INFORMATION *arg2)
|
---|
186 | {
|
---|
187 | DWORD rc;
|
---|
188 | HFILE hFile;
|
---|
189 |
|
---|
190 | /* @@@PH experimental Handlemanager support */
|
---|
191 | if (HMHandleTranslateToOS2(arg1,
|
---|
192 | &hFile) == NO_ERROR)
|
---|
193 | arg1 = hFile;
|
---|
194 |
|
---|
195 |
|
---|
196 | rc = O32_GetFileInformationByHandle(arg1,
|
---|
197 | arg2);
|
---|
198 |
|
---|
199 | dprintf(("KERNEL32: GetFileInformationByHandle (%08xh) returned %08xh\n",
|
---|
200 | arg1,
|
---|
201 | rc));
|
---|
202 |
|
---|
203 | /* @@@PH irrelevant
|
---|
204 | if(rc == 0)
|
---|
205 | {
|
---|
206 | //might be converted _lopen handle, so go get it
|
---|
207 | // arg1 = ConvertHandle(arg1);
|
---|
208 | rc = O32_GetFileInformationByHandle(arg1, arg2);
|
---|
209 | dprintf(("KERNEL32: GetFileInformationByHandle (%X) returned %d\n", arg1, rc));
|
---|
210 | }
|
---|
211 | */
|
---|
212 |
|
---|
213 | return(rc);
|
---|
214 | }
|
---|
215 | //******************************************************************************
|
---|
216 | //******************************************************************************
|
---|
217 | BOOL WIN32API SetEndOfFile( HANDLE arg1)
|
---|
218 | {
|
---|
219 | HFILE hFile;
|
---|
220 |
|
---|
221 | /* @@@PH experimental Handlemanager support */
|
---|
222 | if (HMHandleTranslateToOS2(arg1,
|
---|
223 | &hFile) == NO_ERROR)
|
---|
224 | arg1 = hFile;
|
---|
225 |
|
---|
226 | dprintf(("KERNEL32: SetEndOfFile(%08xh)\n",
|
---|
227 | arg1));
|
---|
228 |
|
---|
229 | return O32_SetEndOfFile(arg1);
|
---|
230 | }
|
---|
231 | //******************************************************************************
|
---|
232 | //******************************************************************************
|
---|
233 | BOOL WIN32API SetFileTime(HANDLE arg1,
|
---|
234 | const FILETIME *arg2,
|
---|
235 | const FILETIME *arg3,
|
---|
236 | const FILETIME *arg4)
|
---|
237 | {
|
---|
238 | HFILE hFile;
|
---|
239 |
|
---|
240 | /* @@@PH experimental Handlemanager support */
|
---|
241 | if (HMHandleTranslateToOS2(arg1,
|
---|
242 | &hFile) == NO_ERROR)
|
---|
243 | arg1 = hFile;
|
---|
244 |
|
---|
245 | dprintf(("KERNEL32: SetFileTime(%08xh,%08xh,%08xh,%08xh)\n",
|
---|
246 | arg1,
|
---|
247 | arg2,
|
---|
248 | arg3,
|
---|
249 | arg4));
|
---|
250 |
|
---|
251 | return O32_SetFileTime(arg1,
|
---|
252 | arg2,
|
---|
253 | arg3,
|
---|
254 | arg4);
|
---|
255 | }
|
---|
256 | //******************************************************************************
|
---|
257 | //******************************************************************************
|
---|
258 | INT WIN32API CompareFileTime( FILETIME * arg1, FILETIME * arg2)
|
---|
259 | {
|
---|
260 | dprintf(("KERNEL32: CompareFileTime\n"));
|
---|
261 | return O32_CompareFileTime(arg1, arg2);
|
---|
262 | }
|
---|
263 | //******************************************************************************
|
---|
264 | //******************************************************************************
|
---|
265 | BOOL WIN32API CopyFileA(LPCSTR arg1, LPCSTR arg2, BOOL arg3)
|
---|
266 | {
|
---|
267 | dprintf(("KERNEL32: CopyFile %s %s\n", arg1, arg2));
|
---|
268 | return O32_CopyFile(arg1, arg2, arg3);
|
---|
269 | }
|
---|
270 | //******************************************************************************
|
---|
271 | //SvL: 24-6-'97 - Added
|
---|
272 | //******************************************************************************
|
---|
273 | BOOL WIN32API CopyFileW(LPCWSTR arg1, LPCWSTR arg2, BOOL arg3)
|
---|
274 | {
|
---|
275 | BOOL rc;
|
---|
276 | char *astring1, *astring2;
|
---|
277 |
|
---|
278 | astring1 = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
279 | astring2 = UnicodeToAsciiString((LPWSTR)arg2);
|
---|
280 | dprintf(("KERNEL32: CopyFileW\n"));
|
---|
281 | rc = O32_CopyFile(astring1, astring2, arg3);
|
---|
282 | FreeAsciiString(astring2);
|
---|
283 | FreeAsciiString(astring1);
|
---|
284 | return(rc);
|
---|
285 | }
|
---|
286 | //******************************************************************************
|
---|
287 | //******************************************************************************
|
---|
288 | DWORD WIN32API GetFileSize( HANDLE arg1, PDWORD arg2)
|
---|
289 | {
|
---|
290 | HFILE hFile;
|
---|
291 |
|
---|
292 | /* @@@PH experimental Handlemanager support */
|
---|
293 | if (HMHandleTranslateToOS2(arg1,
|
---|
294 | &hFile) == NO_ERROR)
|
---|
295 | arg1 = hFile;
|
---|
296 |
|
---|
297 | dprintf(("KERNEL32: GetFileSize (%08xh, %08xh)\n",
|
---|
298 | arg1,
|
---|
299 | arg2));
|
---|
300 |
|
---|
301 | return O32_GetFileSize(arg1,
|
---|
302 | arg2);
|
---|
303 | }
|
---|
304 | //******************************************************************************
|
---|
305 | //******************************************************************************
|
---|
306 | BOOL WIN32API DeleteFileA(LPCSTR arg1)
|
---|
307 | {
|
---|
308 | dprintf(("KERNEL32: DeleteFile %s\n", arg1));
|
---|
309 | return O32_DeleteFile(arg1);
|
---|
310 | }
|
---|
311 | //******************************************************************************
|
---|
312 | //******************************************************************************
|
---|
313 | BOOL WIN32API DeleteFileW(LPCWSTR arg1)
|
---|
314 | {
|
---|
315 | BOOL rc;
|
---|
316 | char *astring;
|
---|
317 |
|
---|
318 | dprintf(("KERNEL32: DeleteFileW\n"));
|
---|
319 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
320 | rc = O32_DeleteFile(astring);
|
---|
321 | FreeAsciiString(astring);
|
---|
322 | return(rc);
|
---|
323 | }
|
---|
324 | //******************************************************************************
|
---|
325 | //******************************************************************************
|
---|
326 | UINT WIN32API GetTempFileNameA(LPCSTR arg1, LPCSTR arg2, UINT arg3, LPSTR arg4)
|
---|
327 | {
|
---|
328 | dprintf(("KERNEL32: GetTempFileName"));
|
---|
329 | return O32_GetTempFileName(arg1, arg2, arg3, arg4);
|
---|
330 | }
|
---|
331 | //******************************************************************************
|
---|
332 | //******************************************************************************
|
---|
333 | UINT WIN32API GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString,
|
---|
334 | UINT uUnique, LPWSTR lpTempFileName)
|
---|
335 | {
|
---|
336 | char *asciipath, *asciiprefix;
|
---|
337 | char *asciitemp = (char *)malloc(MAX_PATH+1);
|
---|
338 | UINT rc;
|
---|
339 |
|
---|
340 | dprintf(("KERNEL32: GetTempFileNameW"));
|
---|
341 | asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
|
---|
342 | asciiprefix = UnicodeToAsciiString((LPWSTR)lpPrefixString);
|
---|
343 | rc = O32_GetTempFileName(asciipath, asciiprefix, uUnique, asciitemp);
|
---|
344 | if(rc) AsciiToUnicode(asciitemp, lpTempFileName);
|
---|
345 | FreeAsciiString(asciiprefix);
|
---|
346 | FreeAsciiString(asciipath);
|
---|
347 | free(asciitemp);
|
---|
348 | return(rc);
|
---|
349 | }
|
---|
350 | //******************************************************************************
|
---|
351 | //******************************************************************************
|
---|
352 | UINT WIN32API GetTempPathA(UINT arg1, LPSTR arg2)
|
---|
353 | {
|
---|
354 | dprintf(("KERNEL32: GetTempPath\n"));
|
---|
355 | return O32_GetTempPath(arg1, arg2);
|
---|
356 | }
|
---|
357 | //******************************************************************************
|
---|
358 | //******************************************************************************
|
---|
359 | UINT WIN32API GetTempPathW(UINT nBufferLength, LPWSTR lpBuffer)
|
---|
360 | {
|
---|
361 | char *asciibuffer = (char *)malloc(nBufferLength+1);
|
---|
362 | DWORD rc;
|
---|
363 |
|
---|
364 | dprintf(("KERNEL32: GetTempPathW\n"));
|
---|
365 | rc = O32_GetTempPath(nBufferLength, asciibuffer);
|
---|
366 | if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
|
---|
367 | free(asciibuffer);
|
---|
368 | return(rc);
|
---|
369 | }
|
---|
370 | //******************************************************************************
|
---|
371 | //******************************************************************************
|
---|
372 | BOOL WIN32API ReadFile(HANDLE arg1,
|
---|
373 | PVOID arg2,
|
---|
374 | DWORD arg3,
|
---|
375 | PDWORD arg4,
|
---|
376 | LPOVERLAPPED arg5)
|
---|
377 | {
|
---|
378 | BOOL rc;
|
---|
379 | HFILE hFile;
|
---|
380 |
|
---|
381 | /* @@@PH 1998/02/12 Handle Manager support */
|
---|
382 | if (IS_HM_HANDLE(arg1))
|
---|
383 | return (HMReadFile(arg1, arg2, arg3, arg4, arg5));
|
---|
384 |
|
---|
385 | /* @@@PH 1999/06/09 Handle Manager support */
|
---|
386 |
|
---|
387 | /* @@@PH experimental Handlemanager support */
|
---|
388 | if (HMHandleTranslateToOS2(arg1,
|
---|
389 | &hFile) == NO_ERROR)
|
---|
390 | arg1 = hFile;
|
---|
391 |
|
---|
392 | rc = O32_ReadFile(arg1,
|
---|
393 | arg2,
|
---|
394 | arg3,
|
---|
395 | arg4,
|
---|
396 | arg5);
|
---|
397 |
|
---|
398 | dprintf(("KERNEL32: ReadFile %X %d bytes returned %d\n",
|
---|
399 | arg1,
|
---|
400 | arg3,
|
---|
401 | rc));
|
---|
402 |
|
---|
403 | return(rc);
|
---|
404 | }
|
---|
405 | //******************************************************************************
|
---|
406 | //******************************************************************************
|
---|
407 | DWORD WIN32API SetFilePointer(HANDLE hFile,
|
---|
408 | LONG lDistanceToMove,
|
---|
409 | PLONG lpDistanceToMoveHigh,
|
---|
410 | DWORD dwMoveMethod)
|
---|
411 | {
|
---|
412 | HANDLE hFile2;
|
---|
413 |
|
---|
414 | // dprintf(("KERNEL32: SetFilePointer\n"));
|
---|
415 |
|
---|
416 | /* @@@PH experimental Handlemanager support */
|
---|
417 | if (HMHandleTranslateToOS2(hFile,
|
---|
418 | &hFile2) == NO_ERROR)
|
---|
419 | hFile = hFile2;
|
---|
420 |
|
---|
421 | return(O32_SetFilePointer(hFile,
|
---|
422 | lDistanceToMove,
|
---|
423 | lpDistanceToMoveHigh,
|
---|
424 | dwMoveMethod));
|
---|
425 | }
|
---|
426 | //******************************************************************************
|
---|
427 | //******************************************************************************
|
---|
428 | BOOL WIN32API WriteFile(HANDLE hFile,
|
---|
429 | LPCVOID buffer,
|
---|
430 | DWORD nrbytes,
|
---|
431 | LPDWORD nrbyteswritten,
|
---|
432 | LPOVERLAPPED lpOverlapped)
|
---|
433 | {
|
---|
434 | BOOL rc;
|
---|
435 | HANDLE hFile2;
|
---|
436 |
|
---|
437 | //@@@PH translate handle
|
---|
438 | //KSO Aug 31 1998: when writing 0 bytes to a file win32 sets eof here.
|
---|
439 | if (nrbytes == 0 && !IS_HM_HANDLE(hFile))
|
---|
440 | {
|
---|
441 | *nrbyteswritten = 0;
|
---|
442 | return O32_SetEndOfFile(hFile);
|
---|
443 | }
|
---|
444 |
|
---|
445 | /* @@@PH 1998/02/12 Handle Manager support */
|
---|
446 | if (IS_HM_HANDLE(hFile))
|
---|
447 | return (HMWriteFile(hFile,
|
---|
448 | buffer,
|
---|
449 | nrbytes,
|
---|
450 | nrbyteswritten,
|
---|
451 | lpOverlapped));
|
---|
452 |
|
---|
453 | /* @@@PH experimental Handlemanager support */
|
---|
454 | if (HMHandleTranslateToOS2(hFile,
|
---|
455 | &hFile2) == NO_ERROR)
|
---|
456 | hFile = hFile2;
|
---|
457 |
|
---|
458 |
|
---|
459 | rc = O32_WriteFile(hFile, buffer, nrbytes, nrbyteswritten, (LPOVERLAPPED)lpOverlapped);
|
---|
460 | if(rc == 0 && GetLastError() == 436) { //ERROR_VIO_INVALID_HANDLE (OS/2)
|
---|
461 | //// dprintf(("KERNEL32: WriteFile %s\n", buffer));
|
---|
462 | return(TRUE);
|
---|
463 | }
|
---|
464 | dprintf(("KERNEL32: WriteFile handle = %X, %d bytes, returned %d (%X)\n", hFile, nrbytes, rc, GetLastError()));
|
---|
465 | return(rc);
|
---|
466 | }
|
---|
467 | //******************************************************************************
|
---|
468 | //******************************************************************************
|
---|
469 | DWORD WIN32API SearchPathA( LPCSTR arg1, LPCSTR arg2, LPCSTR arg3, DWORD arg4, LPSTR arg5, LPSTR * arg6)
|
---|
470 | {
|
---|
471 | dprintf(("KERNEL32: SearchPathA\n"));
|
---|
472 | return O32_SearchPath(arg1, arg2, arg3, arg4, arg5, arg6);
|
---|
473 | }
|
---|
474 | //******************************************************************************
|
---|
475 | //******************************************************************************
|
---|
476 | DWORD WIN32API SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension,
|
---|
477 | DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart)
|
---|
478 | {
|
---|
479 | char *asciipath, *asciifile, *asciiext, *asciibuffer, *asciipart;
|
---|
480 | DWORD rc;
|
---|
481 |
|
---|
482 | dprintf(("KERNEL32: SearchPathW"));
|
---|
483 | asciibuffer = (char *)malloc(nBufferLength+1);
|
---|
484 | asciipath = UnicodeToAsciiString((LPWSTR)lpPath);
|
---|
485 | asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
|
---|
486 | asciiext = UnicodeToAsciiString((LPWSTR)lpFileName);
|
---|
487 | rc = O32_SearchPath(asciipath, asciifile, asciiext, nBufferLength, asciibuffer, &asciipart);
|
---|
488 |
|
---|
489 | if(rc) {
|
---|
490 | AsciiToUnicode(asciibuffer, lpBuffer);
|
---|
491 | *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
|
---|
492 | }
|
---|
493 | FreeAsciiString(asciiext);
|
---|
494 | FreeAsciiString(asciifile);
|
---|
495 | FreeAsciiString(asciipath);
|
---|
496 | free(asciibuffer);
|
---|
497 | return(rc);
|
---|
498 | }
|
---|
499 | //******************************************************************************
|
---|
500 | //******************************************************************************
|
---|
501 | DWORD WIN32API GetFileAttributesA(LPCSTR lpszFileName)
|
---|
502 | {
|
---|
503 | DWORD rc;
|
---|
504 |
|
---|
505 | rc = O32_GetFileAttributes((LPSTR)lpszFileName);
|
---|
506 | dprintf(("KERNEL32: GetFileAttributes of %s returned %d\n", lpszFileName, rc));
|
---|
507 | return(rc);
|
---|
508 | }
|
---|
509 | //******************************************************************************
|
---|
510 | //******************************************************************************
|
---|
511 | DWORD WIN32API GetFileAttributesW(LPCWSTR arg1)
|
---|
512 | {
|
---|
513 | DWORD rc;
|
---|
514 | char *astring;
|
---|
515 |
|
---|
516 | dprintf(("KERNEL32: GetFileAttributesW\n"));
|
---|
517 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
518 | rc = O32_GetFileAttributes(astring);
|
---|
519 | FreeAsciiString(astring);
|
---|
520 | return(rc);
|
---|
521 | }
|
---|
522 | //******************************************************************************
|
---|
523 | //******************************************************************************
|
---|
524 | BOOL WIN32API SetFileAttributesA(LPCSTR arg1, DWORD arg2)
|
---|
525 | {
|
---|
526 | dprintf(("KERNEL32: SetFileAttributes of %s\n", arg1));
|
---|
527 | return O32_SetFileAttributes(arg1, arg2);
|
---|
528 | }
|
---|
529 | //******************************************************************************
|
---|
530 | //******************************************************************************
|
---|
531 | BOOL WIN32API SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
|
---|
532 | {
|
---|
533 | char *asciifile;
|
---|
534 | BOOL rc;
|
---|
535 |
|
---|
536 | dprintf(("KERNEL32: SetFileAttributesW\n"));
|
---|
537 | asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
|
---|
538 | rc = O32_SetFileAttributes(asciifile, dwFileAttributes);
|
---|
539 | FreeAsciiString(asciifile);
|
---|
540 | return(rc);
|
---|
541 | }
|
---|
542 | //******************************************************************************
|
---|
543 | //******************************************************************************
|
---|
544 | DWORD WIN32API GetFullPathNameA(LPCSTR arg1, DWORD arg2, LPSTR arg3, LPSTR *arg4)
|
---|
545 | {
|
---|
546 | dprintf(("KERNEL32: GetFullPathName %s\n", arg1));
|
---|
547 | return O32_GetFullPathName(arg1, arg2, arg3, arg4);
|
---|
548 | }
|
---|
549 | //******************************************************************************
|
---|
550 | //******************************************************************************
|
---|
551 | DWORD WIN32API GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength,
|
---|
552 | LPWSTR lpBuffer, LPWSTR *lpFilePart)
|
---|
553 | {
|
---|
554 | char *astring, *asciibuffer, *asciipart;
|
---|
555 | DWORD rc;
|
---|
556 |
|
---|
557 | dprintf(("KERNEL32: GetFullPathNameW\n"));
|
---|
558 | asciibuffer = (char *)malloc(nBufferLength+1);
|
---|
559 | astring = UnicodeToAsciiString((LPWSTR)lpFileName);
|
---|
560 |
|
---|
561 | rc = O32_GetFullPathName(astring,
|
---|
562 | nBufferLength,
|
---|
563 | asciibuffer,
|
---|
564 | &asciipart);
|
---|
565 |
|
---|
566 | dprintf(("KERNEL32: GetFullPathNameW %s returns %s\n",
|
---|
567 | astring,
|
---|
568 | asciibuffer));
|
---|
569 |
|
---|
570 | if(rc)
|
---|
571 | AsciiToUnicode(asciibuffer,
|
---|
572 | lpBuffer);
|
---|
573 |
|
---|
574 | *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
|
---|
575 |
|
---|
576 | FreeAsciiString(astring);
|
---|
577 | free(asciibuffer);
|
---|
578 | return(rc);
|
---|
579 | }
|
---|
580 | //******************************************************************************
|
---|
581 | //******************************************************************************
|
---|
582 | BOOL WIN32API LockFile(HANDLE arg1,
|
---|
583 | DWORD arg2,
|
---|
584 | DWORD arg3,
|
---|
585 | DWORD arg4,
|
---|
586 | DWORD arg5)
|
---|
587 | {
|
---|
588 | HFILE hFile;
|
---|
589 |
|
---|
590 | /* @@@PH experimental Handlemanager support */
|
---|
591 | if (HMHandleTranslateToOS2(arg1,
|
---|
592 | &hFile) == NO_ERROR)
|
---|
593 | arg1 = hFile;
|
---|
594 |
|
---|
595 | dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
---|
596 | arg1,
|
---|
597 | arg2,
|
---|
598 | arg3,
|
---|
599 | arg4,
|
---|
600 | arg5));
|
---|
601 |
|
---|
602 | return O32_LockFile(arg1,
|
---|
603 | arg2,
|
---|
604 | arg3,
|
---|
605 | arg4,
|
---|
606 | arg5);
|
---|
607 | }
|
---|
608 |
|
---|
609 |
|
---|
610 | /*****************************************************************************
|
---|
611 | * Name : BOOL LockFileEx
|
---|
612 | * Purpose : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
|
---|
613 | * Parameters: HANDLE hFile handle of file to lock
|
---|
614 | * DWORD dwFlags functional behavior modification flags
|
---|
615 | * DWORD dwReserved reserved, must be set to zero
|
---|
616 | * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
|
---|
617 | * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
|
---|
618 | * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
|
---|
619 | * Variables :
|
---|
620 | * Result : TRUE / FALSE
|
---|
621 | * Remark :
|
---|
622 | * Status : UNTESTED STUB
|
---|
623 | *
|
---|
624 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
625 | *****************************************************************************/
|
---|
626 |
|
---|
627 | BOOL WIN32API LockFileEx(HANDLE hFile,
|
---|
628 | DWORD dwFlags,
|
---|
629 | DWORD dwReserved,
|
---|
630 | DWORD nNumberOfBytesToLockLow,
|
---|
631 | DWORD nNumberOfBytesToLockHigh,
|
---|
632 | LPOVERLAPPED LPOVERLAPPED)
|
---|
633 | {
|
---|
634 | HFILE hFile2;
|
---|
635 |
|
---|
636 | /* @@@PH experimental Handlemanager support */
|
---|
637 | if (HMHandleTranslateToOS2(hFile,
|
---|
638 | &hFile2) == NO_ERROR)
|
---|
639 | hFile = hFile2;
|
---|
640 |
|
---|
641 | dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
---|
642 | hFile,
|
---|
643 | dwFlags,
|
---|
644 | dwReserved,
|
---|
645 | nNumberOfBytesToLockLow,
|
---|
646 | nNumberOfBytesToLockHigh,
|
---|
647 | LPOVERLAPPED));
|
---|
648 |
|
---|
649 | return(O32_LockFile(hFile,
|
---|
650 | LPOVERLAPPED->Offset,
|
---|
651 | LPOVERLAPPED->OffsetHigh,
|
---|
652 | nNumberOfBytesToLockLow,
|
---|
653 | nNumberOfBytesToLockHigh));
|
---|
654 | }
|
---|
655 |
|
---|
656 |
|
---|
657 |
|
---|
658 |
|
---|
659 | //******************************************************************************
|
---|
660 | //******************************************************************************
|
---|
661 | BOOL WIN32API MoveFileA( LPCSTR arg1, LPCSTR arg2)
|
---|
662 | {
|
---|
663 | dprintf(("KERNEL32: MoveFileA\n"));
|
---|
664 | return O32_MoveFile(arg1, arg2);
|
---|
665 | }
|
---|
666 | //******************************************************************************
|
---|
667 | //******************************************************************************
|
---|
668 | BOOL WIN32API MoveFileExA(LPCSTR arg1,
|
---|
669 | LPCSTR arg2,
|
---|
670 | DWORD fdwFlags)
|
---|
671 | {
|
---|
672 | dprintf(("KERNEL32: MoveFileExA %s to %s, not complete!\n", arg1, arg2));
|
---|
673 | return O32_MoveFile(arg1, arg2);
|
---|
674 | }
|
---|
675 | //******************************************************************************
|
---|
676 | //******************************************************************************
|
---|
677 | BOOL WIN32API MoveFileW(LPCWSTR lpSrc, LPCWSTR lpDest)
|
---|
678 | {
|
---|
679 | char *asciisrc, *asciidest;
|
---|
680 | BOOL rc;
|
---|
681 |
|
---|
682 | dprintf(("KERNEL32: MoveFileW\n"));
|
---|
683 | asciisrc = UnicodeToAsciiString((LPWSTR)lpSrc);
|
---|
684 | asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
|
---|
685 | rc = O32_MoveFile(asciisrc, asciidest);
|
---|
686 | FreeAsciiString(asciisrc);
|
---|
687 | FreeAsciiString(asciidest);
|
---|
688 | return(rc);
|
---|
689 | }
|
---|
690 | //******************************************************************************
|
---|
691 | //******************************************************************************
|
---|
692 | BOOL WIN32API MoveFileExW(LPCWSTR arg1,
|
---|
693 | LPCWSTR arg2,
|
---|
694 | DWORD fdwFlags)
|
---|
695 | {
|
---|
696 | dprintf(("KERNEL32: MoveFileExW %s to %s, not complete!\n", arg1, arg2));
|
---|
697 | return MoveFileW(arg1, arg2);
|
---|
698 | }
|
---|
699 | //******************************************************************************
|
---|
700 | /*****************************************************************************
|
---|
701 | * Name : HFILE WIN32API OpenFile
|
---|
702 | * Purpose : forward OpenFile to Open32
|
---|
703 | * Parameters:
|
---|
704 | * Variables :
|
---|
705 | * Result : API returncode
|
---|
706 | * Remark : modified for handle translation support
|
---|
707 | * Status : @@@PH verify if 0 is a valid "invalid handle" :)
|
---|
708 | *
|
---|
709 | * Author : Patrick Haller [Fri, 1998/06/12 02:53]
|
---|
710 | *****************************************************************************/
|
---|
711 |
|
---|
712 | HFILE WIN32API OpenFile(LPCSTR arg1,
|
---|
713 | OFSTRUCT *arg2,
|
---|
714 | UINT arg3)
|
---|
715 | {
|
---|
716 | HFILE hFile;
|
---|
717 | ULONG ulWindowsHandle; /* translated windows handle */
|
---|
718 |
|
---|
719 | dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
|
---|
720 | arg1,
|
---|
721 | arg2,
|
---|
722 | arg3));
|
---|
723 |
|
---|
724 | hFile = O32_OpenFile(arg1, /* call open32 */
|
---|
725 | arg2,
|
---|
726 | arg3);
|
---|
727 |
|
---|
728 | /* @@@PH 1999/06/09 HandleManager support temporarily disabled */
|
---|
729 | if (hFile != 0) /* check if handle is valid */
|
---|
730 | {
|
---|
731 | if (HMHandleAllocate(&ulWindowsHandle, /* allocate translation handle */
|
---|
732 | hFile) == NO_ERROR)
|
---|
733 | return (ulWindowsHandle);
|
---|
734 | }
|
---|
735 |
|
---|
736 | return (hFile);
|
---|
737 | }
|
---|
738 | //******************************************************************************
|
---|
739 | //******************************************************************************
|
---|
740 | BOOL WIN32API UnlockFile(HANDLE arg1,
|
---|
741 | DWORD arg2,
|
---|
742 | DWORD arg3,
|
---|
743 | DWORD arg4,
|
---|
744 | DWORD arg5)
|
---|
745 | {
|
---|
746 | HFILE hFile2;
|
---|
747 |
|
---|
748 | /* @@@PH experimental Handlemanager support */
|
---|
749 | if (HMHandleTranslateToOS2(arg1,
|
---|
750 | &hFile2) == NO_ERROR)
|
---|
751 | arg1 = hFile2;
|
---|
752 |
|
---|
753 | dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
---|
754 | arg1,
|
---|
755 | arg2,
|
---|
756 | arg3,
|
---|
757 | arg4,
|
---|
758 | arg5));
|
---|
759 |
|
---|
760 | return O32_UnlockFile(arg1,
|
---|
761 | arg2,
|
---|
762 | arg3,
|
---|
763 | arg4,
|
---|
764 | arg5);
|
---|
765 | }
|
---|
766 |
|
---|
767 |
|
---|
768 | /*****************************************************************************
|
---|
769 | * Name : BOOL UnlockFileEx
|
---|
770 | * Purpose : The UnlockFileEx function unlocks a previously locked byte range in an open file.
|
---|
771 | * Parameters: HANDLE hFile handle of file to lock
|
---|
772 | * DWORD dwReserved reserved, must be set to zero
|
---|
773 | * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
|
---|
774 | * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
|
---|
775 | * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
|
---|
776 | * Variables :
|
---|
777 | * Result : TRUE / FALSE
|
---|
778 | * Remark :
|
---|
779 | * Status : UNTESTED STUB
|
---|
780 | *
|
---|
781 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
782 | *****************************************************************************/
|
---|
783 |
|
---|
784 | BOOL WIN32API UnlockFileEx(HANDLE hFile,
|
---|
785 | DWORD dwReserved,
|
---|
786 | DWORD nNumberOfBytesToLockLow,
|
---|
787 | DWORD nNumberOfBytesToLockHigh,
|
---|
788 | LPOVERLAPPED LPOVERLAPPED)
|
---|
789 | {
|
---|
790 | HFILE hFile2;
|
---|
791 |
|
---|
792 | /* @@@PH experimental Handlemanager support */
|
---|
793 | if (HMHandleTranslateToOS2(hFile,
|
---|
794 | &hFile2) == NO_ERROR)
|
---|
795 | hFile = hFile2;
|
---|
796 |
|
---|
797 | dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
---|
798 | hFile,
|
---|
799 | dwReserved,
|
---|
800 | nNumberOfBytesToLockLow,
|
---|
801 | nNumberOfBytesToLockHigh,
|
---|
802 | LPOVERLAPPED));
|
---|
803 |
|
---|
804 | return(O32_UnlockFile(hFile,
|
---|
805 | LPOVERLAPPED->Offset,
|
---|
806 | LPOVERLAPPED->OffsetHigh,
|
---|
807 | nNumberOfBytesToLockLow,
|
---|
808 | nNumberOfBytesToLockHigh));
|
---|
809 | }
|
---|
810 | //******************************************************************************
|
---|
811 | //******************************************************************************
|
---|
812 | DWORD WIN32API GetShortPathNameA(LPCTSTR lpszLongPath, LPTSTR lpszShortPath,
|
---|
813 | DWORD cchBuffer)
|
---|
814 | {
|
---|
815 | int length;
|
---|
816 |
|
---|
817 | dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it\n", lpszLongPath));
|
---|
818 | length = strlen(lpszLongPath) + 1;
|
---|
819 | if(length > cchBuffer) {
|
---|
820 | *lpszShortPath = 0;
|
---|
821 | return(length);
|
---|
822 | }
|
---|
823 | memcpy(lpszShortPath, lpszLongPath, length);
|
---|
824 | return(length-1);
|
---|
825 | }
|
---|
826 | //******************************************************************************
|
---|
827 | //******************************************************************************
|
---|
828 | DWORD WIN32API GetShortPathNameW(LPCWSTR lpszLongPath, LPWSTR lpszShortPath,
|
---|
829 | DWORD cchBuffer)
|
---|
830 | {
|
---|
831 | int length;
|
---|
832 |
|
---|
833 | dprintf(("KERNEL32: GetShortPathNameW; just copying it\n"));
|
---|
834 | length = UniStrlen((UniChar*)lpszLongPath) + 1;
|
---|
835 | if(length > cchBuffer) {
|
---|
836 | *lpszShortPath = 0;
|
---|
837 | return(length);
|
---|
838 | }
|
---|
839 | memcpy(lpszShortPath, lpszLongPath, length*sizeof(USHORT));
|
---|
840 | return(length-1);
|
---|
841 | }
|
---|
842 | //******************************************************************************
|
---|
843 | //******************************************************************************
|
---|
844 | HANDLE WIN32API FindFirstChangeNotificationA(LPCSTR lpPathName, BOOL bWatchSubtree,
|
---|
845 | DWORD dwNotifyFilter)
|
---|
846 | {
|
---|
847 | dprintf(("KERNEL32: FindFirstChangeNotificationA, Not implemented\n"));
|
---|
848 | return(0);
|
---|
849 | }
|
---|
850 | //******************************************************************************
|
---|
851 | //******************************************************************************
|
---|
852 | BOOL WIN32API FindNextChangeNotification(HANDLE hChange)
|
---|
853 | {
|
---|
854 | dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
|
---|
855 | hChange));
|
---|
856 |
|
---|
857 | return(0);
|
---|
858 | }
|
---|
859 | //******************************************************************************
|
---|
860 | //******************************************************************************
|
---|
861 | VOID WIN32API SetFileApisToANSI( VOID ) /*PLF Tue 98-02-10 00:52:22*/
|
---|
862 | {
|
---|
863 | dprintf(("SetFileApisToANSI() stub\n"));
|
---|
864 | }
|
---|
865 |
|
---|
866 | /*****************************************************************************
|
---|
867 | * Name : DWORD GetCompressedFileSizeA
|
---|
868 | * Purpose : The GetCompressedFileSizeA function obtains the compressed
|
---|
869 | * size, in bytes, of a specified file.
|
---|
870 | * Parameters: LPCTSTR lpFileName, // pointer to name of file
|
---|
871 | * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
|
---|
872 | * high-order doubleword of file size
|
---|
873 | * Variables :
|
---|
874 | * Result : size of compressed file
|
---|
875 | * Remark :
|
---|
876 | * Status : UNTESTED
|
---|
877 | *
|
---|
878 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
879 | *****************************************************************************/
|
---|
880 |
|
---|
881 | DWORD WIN32API GetCompressedFileSizeA(LPCTSTR lpFileName,
|
---|
882 | LPDWORD lpFileSizeHigh)
|
---|
883 | {
|
---|
884 | dprintf(("KERNEL32: GetCompressedFileSizeA (%s, %08xh) not implemented.\n",
|
---|
885 | lpFileName,
|
---|
886 | lpFileSizeHigh));
|
---|
887 |
|
---|
888 | /* PH: simply return the standard filesize */
|
---|
889 | return 0;
|
---|
890 | }
|
---|
891 |
|
---|
892 |
|
---|
893 | /*****************************************************************************
|
---|
894 | * Name : DWORD GetCompressedFileSizeW
|
---|
895 | * Purpose : The GetCompressedFileSizeE function obtains the compressed
|
---|
896 | * size, in bytes, of a specified file.
|
---|
897 | * Parameters: LPCWSTR lpFileName, // pointer to name of file
|
---|
898 | * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
|
---|
899 | * high-order doubleword of file size
|
---|
900 | * Variables :
|
---|
901 | * Result : size of compressed file
|
---|
902 | * Remark :
|
---|
903 | * Status : UNTESTED
|
---|
904 | *
|
---|
905 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
906 | *****************************************************************************/
|
---|
907 |
|
---|
908 | DWORD WIN32API GetCompressedFileSizeW(LPCWSTR lpFileName,
|
---|
909 | LPDWORD lpFileSizeHigh)
|
---|
910 | {
|
---|
911 | LPCTSTR lpAsciiFileName; /* converted filename */
|
---|
912 | DWORD rc; /* function result */
|
---|
913 |
|
---|
914 | dprintf(("KERNEL32: GetCompressedFileSizeW (%s, %08xh)\n",
|
---|
915 | lpFileName,
|
---|
916 | lpFileSizeHigh));
|
---|
917 |
|
---|
918 | lpAsciiFileName = UnicodeToAsciiString( (LPWSTR) lpFileName);
|
---|
919 |
|
---|
920 | rc = GetCompressedFileSizeA(lpAsciiFileName,
|
---|
921 | lpFileSizeHigh);
|
---|
922 |
|
---|
923 | FreeAsciiString( (char *) lpAsciiFileName);
|
---|
924 |
|
---|
925 | return (rc); /* return result */
|
---|
926 | }
|
---|