1 | /* $Id: Fileio.cpp,v 1.47 2001-04-21 11:22:25 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 File IO API functions for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1998-2000 Sander van Leeuwen
|
---|
7 | * Copyright 1998 Patrick Haller
|
---|
8 | *
|
---|
9 | * Some parts copied from Wine (CopyFileExA/W)
|
---|
10 | *
|
---|
11 | * Copyright 1993 John Burton
|
---|
12 | * Copyright 1996 Alexandre Julliard
|
---|
13 | *
|
---|
14 | *
|
---|
15 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
16 | *
|
---|
17 | */
|
---|
18 |
|
---|
19 |
|
---|
20 | /*****************************************************************************
|
---|
21 | * Includes *
|
---|
22 | *****************************************************************************/
|
---|
23 |
|
---|
24 | #include <odin.h>
|
---|
25 | #include <odinwrap.h>
|
---|
26 | #include <os2sel.h>
|
---|
27 |
|
---|
28 | #include <os2win.h>
|
---|
29 | #include <stdlib.h>
|
---|
30 | #include <string.h>
|
---|
31 | #include "unicode.h"
|
---|
32 | #include <heapstring.h>
|
---|
33 | #include "handlemanager.h"
|
---|
34 | #include "oslibdos.h"
|
---|
35 |
|
---|
36 | #define DBG_LOCALLOG DBG_fileio
|
---|
37 | #include "dbglocal.h"
|
---|
38 |
|
---|
39 | ODINDEBUGCHANNEL(KERNEL32-FILEIO)
|
---|
40 |
|
---|
41 | //******************************************************************************
|
---|
42 | //******************************************************************************
|
---|
43 | ODINFUNCTION7(HFILE, CreateFileA,
|
---|
44 | LPCSTR, lpszName,
|
---|
45 | DWORD, fdwAccess,
|
---|
46 | DWORD, fdwShareMode,
|
---|
47 | LPSECURITY_ATTRIBUTES, lpsa,
|
---|
48 | DWORD, fdwCreate,
|
---|
49 | DWORD, fdwAttrsAndFlags,
|
---|
50 | HANDLE, hTemplateFile)
|
---|
51 | {
|
---|
52 | dprintf(("CreateFileA %s", lpszName));
|
---|
53 | return(HMCreateFile(lpszName,
|
---|
54 | fdwAccess,
|
---|
55 | fdwShareMode,
|
---|
56 | lpsa,
|
---|
57 | fdwCreate,
|
---|
58 | fdwAttrsAndFlags,
|
---|
59 | hTemplateFile));
|
---|
60 | }
|
---|
61 |
|
---|
62 | //******************************************************************************
|
---|
63 | //******************************************************************************
|
---|
64 | ODINFUNCTION7(HFILE, CreateFileW,
|
---|
65 | LPCWSTR, arg1,
|
---|
66 | DWORD, arg2,
|
---|
67 | DWORD, arg3,
|
---|
68 | PSECURITY_ATTRIBUTES, arg4,
|
---|
69 | DWORD, arg5,
|
---|
70 | DWORD, arg6,
|
---|
71 | HANDLE, arg7)
|
---|
72 | {
|
---|
73 | HANDLE rc;
|
---|
74 | char *astring;
|
---|
75 |
|
---|
76 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
77 | rc = CreateFileA(astring, arg2, arg3, arg4, arg5, arg6, arg7);
|
---|
78 | FreeAsciiString(astring);
|
---|
79 | return(rc);
|
---|
80 | }
|
---|
81 | //******************************************************************************
|
---|
82 | //******************************************************************************
|
---|
83 | ODINFUNCTION2(HANDLE, FindFirstFileA,
|
---|
84 | LPCSTR, lpFileName,
|
---|
85 | WIN32_FIND_DATAA *, lpFindFileData)
|
---|
86 | {
|
---|
87 | HANDLE hFind;
|
---|
88 | char *filename;
|
---|
89 | int namelen;
|
---|
90 |
|
---|
91 | dprintf(("FindFirstFileA %s", lpFileName));
|
---|
92 |
|
---|
93 | if(lpFileName == NULL || lpFindFileData == NULL)
|
---|
94 | {
|
---|
95 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
96 | return -1;
|
---|
97 | }
|
---|
98 |
|
---|
99 | namelen = strlen(lpFileName);
|
---|
100 | if(lpFileName[namelen-1] == '\\')
|
---|
101 | {
|
---|
102 | filename = (char *)alloca(namelen+1);
|
---|
103 | strcpy(filename, lpFileName);
|
---|
104 | filename[namelen-1] = 0;
|
---|
105 | }
|
---|
106 | else
|
---|
107 | filename = (char *)lpFileName;
|
---|
108 |
|
---|
109 | return (HANDLE)OSLibDosFindFirst(filename,lpFindFileData);
|
---|
110 | }
|
---|
111 | //******************************************************************************
|
---|
112 | // internal function for faster access (SHELL32)
|
---|
113 | //******************************************************************************
|
---|
114 | ODINFUNCTION3(HANDLE, FindFirstFileMultiA,
|
---|
115 | LPCSTR, lpFileName,
|
---|
116 | WIN32_FIND_DATAA *, lpFindFileData,
|
---|
117 | DWORD *,count)
|
---|
118 | {
|
---|
119 | return (HANDLE)OSLibDosFindFirstMulti(lpFileName,lpFindFileData,count);
|
---|
120 | }
|
---|
121 | //******************************************************************************
|
---|
122 | //******************************************************************************
|
---|
123 | ODINFUNCTION2(HANDLE, FindFirstFileW,
|
---|
124 | LPCWSTR, lpFileName,
|
---|
125 | WIN32_FIND_DATAW *, lpFindFileData)
|
---|
126 | {
|
---|
127 | HANDLE rc;
|
---|
128 | char *astring;
|
---|
129 | WIN32_FIND_DATAA wfda;
|
---|
130 |
|
---|
131 | astring = UnicodeToAsciiString((LPWSTR)lpFileName);
|
---|
132 | dprintf(("FindFirstFileW %s", astring));
|
---|
133 | rc = (HANDLE)OSLibDosFindFirst(astring,&wfda);
|
---|
134 |
|
---|
135 | if(rc == -1) {
|
---|
136 | memset(lpFindFileData, 0, sizeof(WIN32_FIND_DATAW));
|
---|
137 | }
|
---|
138 | else {
|
---|
139 | // convert back the result structure
|
---|
140 | memcpy(lpFindFileData,
|
---|
141 | &wfda,
|
---|
142 | sizeof(WIN32_FIND_DATAA));
|
---|
143 |
|
---|
144 | lstrcpynAtoW (lpFindFileData->cFileName,
|
---|
145 | wfda.cFileName,
|
---|
146 | sizeof(wfda.cFileName));
|
---|
147 |
|
---|
148 | lstrcpynAtoW (lpFindFileData->cAlternateFileName,
|
---|
149 | wfda.cAlternateFileName,
|
---|
150 | sizeof(wfda.cAlternateFileName));
|
---|
151 | }
|
---|
152 | FreeAsciiString(astring);
|
---|
153 | return(rc);
|
---|
154 | }
|
---|
155 | //******************************************************************************
|
---|
156 | //******************************************************************************
|
---|
157 | ODINFUNCTION2(BOOL, FindNextFileA,
|
---|
158 | HANDLE, hFindFile,
|
---|
159 | WIN32_FIND_DATAA *, lpFindFileData)
|
---|
160 | {
|
---|
161 | return OSLibDosFindNext(hFindFile,lpFindFileData);
|
---|
162 | }
|
---|
163 | //******************************************************************************
|
---|
164 | // internal function for faster access (SHELL32)
|
---|
165 | //******************************************************************************
|
---|
166 | ODINFUNCTION3(BOOL, FindNextFileMultiA,
|
---|
167 | HANDLE, hFindFile,
|
---|
168 | WIN32_FIND_DATAA *, lpFindFileData,
|
---|
169 | DWORD *,count)
|
---|
170 | {
|
---|
171 | return OSLibDosFindNextMulti(hFindFile,lpFindFileData,count);
|
---|
172 | }
|
---|
173 | //******************************************************************************
|
---|
174 | //******************************************************************************
|
---|
175 | ODINFUNCTION2(BOOL, FindNextFileW,
|
---|
176 | HANDLE, hFindFile,
|
---|
177 | WIN32_FIND_DATAW *, lpFindFileData)
|
---|
178 | {
|
---|
179 | WIN32_FIND_DATAA wfda;
|
---|
180 | BOOL rc;
|
---|
181 |
|
---|
182 | rc = OSLibDosFindNext(hFindFile,&wfda);
|
---|
183 |
|
---|
184 | if(rc == 0) {
|
---|
185 | memset(lpFindFileData, 0, sizeof(WIN32_FIND_DATAW));
|
---|
186 | }
|
---|
187 | else {
|
---|
188 | // convert back the result structure
|
---|
189 | memcpy(lpFindFileData,
|
---|
190 | &wfda,
|
---|
191 | sizeof(WIN32_FIND_DATAA));
|
---|
192 |
|
---|
193 | lstrcpynAtoW (lpFindFileData->cFileName,
|
---|
194 | wfda.cFileName,
|
---|
195 | sizeof(wfda.cFileName));
|
---|
196 |
|
---|
197 | lstrcpynAtoW (lpFindFileData->cAlternateFileName,
|
---|
198 | wfda.cAlternateFileName,
|
---|
199 | sizeof(wfda.cAlternateFileName));
|
---|
200 | }
|
---|
201 | return rc;
|
---|
202 | }
|
---|
203 | //******************************************************************************
|
---|
204 | //******************************************************************************
|
---|
205 | ODINFUNCTION1(BOOL, FindClose,
|
---|
206 | HANDLE, hFindFile)
|
---|
207 | {
|
---|
208 | return OSLibDosFindClose(hFindFile);
|
---|
209 | }
|
---|
210 | //******************************************************************************
|
---|
211 | //******************************************************************************
|
---|
212 | ODINFUNCTION1(DWORD, GetFileType,
|
---|
213 | HANDLE, hFile)
|
---|
214 | {
|
---|
215 | return(HMGetFileType(hFile));
|
---|
216 | }
|
---|
217 | //******************************************************************************
|
---|
218 | //******************************************************************************
|
---|
219 | ODINFUNCTION2(DWORD, GetFileInformationByHandle,
|
---|
220 | HANDLE, arg1,
|
---|
221 | BY_HANDLE_FILE_INFORMATION *, arg2)
|
---|
222 | {
|
---|
223 | return(HMGetFileInformationByHandle(arg1,arg2));
|
---|
224 | }
|
---|
225 | //******************************************************************************
|
---|
226 | //******************************************************************************
|
---|
227 | ODINFUNCTION1(BOOL, SetEndOfFile,
|
---|
228 | HANDLE, arg1)
|
---|
229 | {
|
---|
230 | return HMSetEndOfFile(arg1);
|
---|
231 | }
|
---|
232 | //******************************************************************************
|
---|
233 | //******************************************************************************
|
---|
234 | ODINFUNCTION4(BOOL, SetFileTime,
|
---|
235 | HANDLE, arg1,
|
---|
236 | const FILETIME *, arg2,
|
---|
237 | const FILETIME *, arg3,
|
---|
238 | const FILETIME *, arg4)
|
---|
239 | {
|
---|
240 | return HMSetFileTime(arg1,
|
---|
241 | arg2,
|
---|
242 | arg3,
|
---|
243 | arg4);
|
---|
244 | }
|
---|
245 | //******************************************************************************
|
---|
246 | //******************************************************************************
|
---|
247 | ODINFUNCTION2(INT, CompareFileTime,
|
---|
248 | FILETIME *, lpft1,
|
---|
249 | FILETIME *, lpft2)
|
---|
250 | {
|
---|
251 | if (lpft1 == NULL || lpft2 == NULL) {
|
---|
252 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
253 | return -1;
|
---|
254 | }
|
---|
255 |
|
---|
256 | if(lpft1->dwHighDateTime > lpft2->dwHighDateTime)
|
---|
257 | return 1;
|
---|
258 |
|
---|
259 | if(lpft1->dwHighDateTime < lpft2->dwHighDateTime)
|
---|
260 | return -1;
|
---|
261 |
|
---|
262 | if(lpft1->dwLowDateTime > lpft2->dwLowDateTime)
|
---|
263 | return 1;
|
---|
264 |
|
---|
265 | if(lpft1->dwLowDateTime < lpft2->dwLowDateTime)
|
---|
266 | return -1;
|
---|
267 |
|
---|
268 | return 0; //equal
|
---|
269 | }
|
---|
270 | //******************************************************************************
|
---|
271 | //******************************************************************************
|
---|
272 | ODINFUNCTION4(BOOL, GetFileTime, HANDLE, hFile, LPFILETIME, arg2, LPFILETIME, arg3, LPFILETIME, arg4)
|
---|
273 | {
|
---|
274 | return HMGetFileTime(hFile, arg2, arg3, arg4);
|
---|
275 | }
|
---|
276 | //******************************************************************************
|
---|
277 | //******************************************************************************
|
---|
278 | ODINFUNCTION3(BOOL, CopyFileA,
|
---|
279 | LPCSTR, arg1,
|
---|
280 | LPCSTR, arg2,
|
---|
281 | BOOL, arg3)
|
---|
282 | {
|
---|
283 | return O32_CopyFile(arg1, arg2, arg3);
|
---|
284 | }
|
---|
285 | //******************************************************************************
|
---|
286 | //SvL: 24-6-'97 - Added
|
---|
287 | //******************************************************************************
|
---|
288 | ODINFUNCTION3(BOOL, CopyFileW,
|
---|
289 | LPCWSTR, arg1,
|
---|
290 | LPCWSTR, arg2,
|
---|
291 | BOOL, arg3)
|
---|
292 | {
|
---|
293 | BOOL rc;
|
---|
294 | char *astring1, *astring2;
|
---|
295 |
|
---|
296 | astring1 = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
297 | astring2 = UnicodeToAsciiString((LPWSTR)arg2);
|
---|
298 | rc = O32_CopyFile(astring1, astring2, arg3);
|
---|
299 | FreeAsciiString(astring2);
|
---|
300 | FreeAsciiString(astring1);
|
---|
301 | return(rc);
|
---|
302 | }
|
---|
303 | /*****************************************************************************
|
---|
304 | * Name : BOOL WIN32API CopyFileExA
|
---|
305 | * Purpose : The CopyFileExA function copies an existing file to a new file.
|
---|
306 | * This function preserves extended attributes, OLE structured
|
---|
307 | * storage, NTFS alternate data streams, and file attributes.
|
---|
308 | * Security attributes for the existing file are not copied to
|
---|
309 | * the new file.
|
---|
310 | * Parameters: LPCSTR lpExistingFileName pointer to name of an existing file
|
---|
311 | * LPCSTR lpNewFileName pointer to filename to copy to
|
---|
312 | * LPPROGRESS_ROUTINE lpProgressRoutine pointer to the callback function
|
---|
313 | * LPVOID lpData to be passed to the callback function
|
---|
314 | * LPBOOL pbCancel flag that can be used to cancel the operation
|
---|
315 | * DWORD dwCopyFlags flags that specify how the file is copied
|
---|
316 | * Variables :
|
---|
317 | * Result : f the function succeeds, the return value is nonzero.
|
---|
318 | * If the function fails, the return value is zero.
|
---|
319 | * To get extended error information call GetLastError.
|
---|
320 | * Remark :
|
---|
321 | * Status : UNTESTED STUB
|
---|
322 | *
|
---|
323 | * Author : Markus Montkowski [Thu, 1998/05/19 11:46]
|
---|
324 | *****************************************************************************/
|
---|
325 |
|
---|
326 | BOOL WIN32API CopyFileExA( LPCSTR lpExistingFileName,
|
---|
327 | LPCSTR lpNewFileName,
|
---|
328 | LPPROGRESS_ROUTINE lpProgressRoutine,
|
---|
329 | LPVOID lpData,
|
---|
330 | LPBOOL pbCancel,
|
---|
331 | DWORD dwCopyFlags)
|
---|
332 | {
|
---|
333 |
|
---|
334 | dprintf(("KERNEL32: CopyFileExA(%08x,%08x,%08x,%08x,%08x,%08x) not properly implemented\n",
|
---|
335 | lpExistingFileName,
|
---|
336 | lpNewFileName,
|
---|
337 | lpProgressRoutine,
|
---|
338 | lpData,
|
---|
339 | pbCancel,
|
---|
340 | dwCopyFlags
|
---|
341 | ));
|
---|
342 |
|
---|
343 | BOOL failIfExists = FALSE;
|
---|
344 |
|
---|
345 | /*
|
---|
346 | * Interpret the only flag that CopyFile can interpret.
|
---|
347 | */
|
---|
348 | if((dwCopyFlags & COPY_FILE_FAIL_IF_EXISTS) != 0)
|
---|
349 | {
|
---|
350 | failIfExists = TRUE;
|
---|
351 | }
|
---|
352 |
|
---|
353 | return CopyFileA(lpExistingFileName, lpNewFileName, failIfExists);
|
---|
354 | }
|
---|
355 |
|
---|
356 |
|
---|
357 | /*****************************************************************************
|
---|
358 | * Name : BOOL WIN32API CopyFileExW
|
---|
359 | * Purpose : The CopyFileExW function copies an existing file to a new file.
|
---|
360 | * This function preserves extended attributes, OLE structured
|
---|
361 | * storage, NTFS alternate data streams, and file attributes.
|
---|
362 | * Security attributes for the existing file are not copied to
|
---|
363 | * the new file.
|
---|
364 | * Parameters: LPCWSTR lpExistingFileName pointer to name of an existing file
|
---|
365 | * LPCWSTR lpNewFileName pointer to filename to copy to
|
---|
366 | * LPPROGRESS_ROUTINE lpProgressRoutine pointer to the callback function
|
---|
367 | * LPVOID lpData to be passed to the callback function
|
---|
368 | * LPBOOL pbCancel flag that can be used to cancel the operation
|
---|
369 | * DWORD dwCopyFlags flags that specify how the file is copied
|
---|
370 | * Variables :
|
---|
371 | * Result : f the function succeeds, the return value is nonzero.
|
---|
372 | * If the function fails, the return value is zero.
|
---|
373 | * To get extended error information call GetLastError.
|
---|
374 | * Remark :
|
---|
375 | * Status : UNTESTED STUB
|
---|
376 | *
|
---|
377 | * Author : Markus Montkowski [Thu, 1998/05/19 11:46]
|
---|
378 | *****************************************************************************/
|
---|
379 |
|
---|
380 | BOOL WIN32API CopyFileExW( LPCWSTR lpExistingFileName,
|
---|
381 | LPCWSTR lpNewFileName,
|
---|
382 | LPPROGRESS_ROUTINE lpProgressRoutine,
|
---|
383 | LPVOID lpData,
|
---|
384 | LPBOOL pbCancel,
|
---|
385 | DWORD dwCopyFlags)
|
---|
386 | {
|
---|
387 | LPSTR sourceA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpExistingFileName );
|
---|
388 | LPSTR destA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpNewFileName );
|
---|
389 |
|
---|
390 | BOOL ret = CopyFileExA(sourceA,
|
---|
391 | destA,
|
---|
392 | lpProgressRoutine,
|
---|
393 | lpData,
|
---|
394 | pbCancel,
|
---|
395 | dwCopyFlags);
|
---|
396 |
|
---|
397 | HeapFree( GetProcessHeap(), 0, sourceA );
|
---|
398 | HeapFree( GetProcessHeap(), 0, destA );
|
---|
399 |
|
---|
400 | return ret;
|
---|
401 | }
|
---|
402 | //******************************************************************************
|
---|
403 | //******************************************************************************
|
---|
404 | ODINFUNCTION2(DWORD, GetFileSize,
|
---|
405 | HANDLE, arg1,
|
---|
406 | PDWORD, arg2)
|
---|
407 | {
|
---|
408 | return HMGetFileSize(arg1,
|
---|
409 | arg2);
|
---|
410 | }
|
---|
411 | //******************************************************************************
|
---|
412 | //******************************************************************************
|
---|
413 | ODINFUNCTION1(BOOL, DeleteFileA,
|
---|
414 | LPCSTR, lpszFile)
|
---|
415 | {
|
---|
416 | BOOL rc;
|
---|
417 |
|
---|
418 | #if 0
|
---|
419 | dprintf(("DeleteFileA %s", lpszFile));
|
---|
420 | return 1;
|
---|
421 | #else
|
---|
422 | rc = OSLibDosDelete((LPSTR)lpszFile);
|
---|
423 | if(!rc) {
|
---|
424 | dprintf(("DeleteFileA %s returned FALSE; last error %x", lpszFile, GetLastError()));
|
---|
425 | if(GetLastError() == 20) {
|
---|
426 | return TRUE;
|
---|
427 | }
|
---|
428 | }
|
---|
429 | else dprintf(("DeleteFileA %s", lpszFile));
|
---|
430 |
|
---|
431 | return rc;
|
---|
432 | #endif
|
---|
433 | }
|
---|
434 | //******************************************************************************
|
---|
435 | //******************************************************************************
|
---|
436 | ODINFUNCTION1(BOOL, DeleteFileW,
|
---|
437 | LPCWSTR, arg1)
|
---|
438 | {
|
---|
439 | BOOL rc;
|
---|
440 | char *astring;
|
---|
441 |
|
---|
442 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
443 | rc = CALL_ODINFUNC(DeleteFileA)(astring);
|
---|
444 | FreeAsciiString(astring);
|
---|
445 | return(rc);
|
---|
446 | }
|
---|
447 | //******************************************************************************
|
---|
448 | //******************************************************************************
|
---|
449 | ODINFUNCTION4(UINT, GetTempFileNameA,
|
---|
450 | LPCSTR, arg1,
|
---|
451 | LPCSTR, arg2,
|
---|
452 | UINT, arg3,
|
---|
453 | LPSTR, arg4)
|
---|
454 | {
|
---|
455 | return O32_GetTempFileName(arg1, arg2, arg3, arg4);
|
---|
456 | }
|
---|
457 | //******************************************************************************
|
---|
458 | //******************************************************************************
|
---|
459 | ODINFUNCTION4(UINT, GetTempFileNameW,
|
---|
460 | LPCWSTR, lpPathName,
|
---|
461 | LPCWSTR, lpPrefixString,
|
---|
462 | UINT, uUnique,
|
---|
463 | LPWSTR, lpTempFileName)
|
---|
464 | {
|
---|
465 | char *asciipath, *asciiprefix;
|
---|
466 | char *asciitemp = (char *)malloc(MAX_PATH+1);
|
---|
467 | UINT rc;
|
---|
468 |
|
---|
469 | asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
|
---|
470 | asciiprefix = UnicodeToAsciiString((LPWSTR)lpPrefixString);
|
---|
471 | rc = O32_GetTempFileName(asciipath, asciiprefix, uUnique, asciitemp);
|
---|
472 | if(rc) AsciiToUnicode(asciitemp, lpTempFileName);
|
---|
473 | FreeAsciiString(asciiprefix);
|
---|
474 | FreeAsciiString(asciipath);
|
---|
475 | free(asciitemp);
|
---|
476 | return(rc);
|
---|
477 | }
|
---|
478 | //******************************************************************************
|
---|
479 | //******************************************************************************
|
---|
480 | ODINFUNCTION2(UINT, GetTempPathA,
|
---|
481 | UINT, arg1,
|
---|
482 | LPSTR, arg2)
|
---|
483 | {
|
---|
484 | return O32_GetTempPath(arg1, arg2);
|
---|
485 | }
|
---|
486 | //******************************************************************************
|
---|
487 | //******************************************************************************
|
---|
488 | ODINFUNCTION2(UINT, GetTempPathW,
|
---|
489 | UINT, nBufferLength,
|
---|
490 | LPWSTR, lpBuffer)
|
---|
491 | {
|
---|
492 | char *asciibuffer = (char *)malloc(nBufferLength+1);
|
---|
493 | DWORD rc;
|
---|
494 |
|
---|
495 | rc = O32_GetTempPath(nBufferLength, asciibuffer);
|
---|
496 | if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
|
---|
497 | free(asciibuffer);
|
---|
498 | return(rc);
|
---|
499 | }
|
---|
500 | //******************************************************************************
|
---|
501 | //******************************************************************************
|
---|
502 | ODINFUNCTION5(BOOL, ReadFile,
|
---|
503 | HANDLE, hFile,
|
---|
504 | PVOID, pBuffer,
|
---|
505 | DWORD, dwLength,
|
---|
506 | PDWORD, lpNumberOfBytesRead,
|
---|
507 | LPOVERLAPPED, lpOverlapped)
|
---|
508 | {
|
---|
509 | return (HMReadFile(hFile,
|
---|
510 | pBuffer,
|
---|
511 | dwLength,
|
---|
512 | lpNumberOfBytesRead,
|
---|
513 | lpOverlapped));
|
---|
514 | }
|
---|
515 | //******************************************************************************
|
---|
516 | //******************************************************************************
|
---|
517 | ODINFUNCTION5(BOOL, ReadFileEx,
|
---|
518 | HANDLE, hFile,
|
---|
519 | LPVOID, lpBuffer,
|
---|
520 | DWORD, nNumberOfBytesToRead,
|
---|
521 | LPOVERLAPPED, lpOverlapped,
|
---|
522 | LPOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine)
|
---|
523 | {
|
---|
524 | return (HMReadFileEx(hFile,
|
---|
525 | lpBuffer,
|
---|
526 | nNumberOfBytesToRead,
|
---|
527 | lpOverlapped, lpCompletionRoutine));
|
---|
528 | }
|
---|
529 | //******************************************************************************
|
---|
530 | //******************************************************************************
|
---|
531 | ODINFUNCTION5(BOOL, WriteFile,
|
---|
532 | HANDLE, hFile,
|
---|
533 | LPCVOID, buffer,
|
---|
534 | DWORD, nrbytes,
|
---|
535 | LPDWORD, nrbyteswritten,
|
---|
536 | LPOVERLAPPED, lpOverlapped)
|
---|
537 | {
|
---|
538 | return (HMWriteFile(hFile,
|
---|
539 | buffer,
|
---|
540 | nrbytes,
|
---|
541 | nrbyteswritten,
|
---|
542 | lpOverlapped));
|
---|
543 | }
|
---|
544 | /*****************************************************************************
|
---|
545 | * Name : BOOL WriteFileEx
|
---|
546 | * Purpose : The WriteFileEx function writes data to a file. It is designed
|
---|
547 | * solely for asynchronous operation, unlike WriteFile, which is
|
---|
548 | * designed for both synchronous and asynchronous operation.
|
---|
549 | * WriteFileEx reports its completion status asynchronously,
|
---|
550 | * calling a specified completion routine when writing is completed
|
---|
551 | * and the calling thread is in an alertable wait state.
|
---|
552 | * Parameters: HANDLE hFile handle of file to write
|
---|
553 | * LPVOID lpBuffer address of buffer
|
---|
554 | * DWORD nNumberOfBytesToRead number of bytes to write
|
---|
555 | * LPOVERLAPPED lpOverlapped address of offset
|
---|
556 | * LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine address of completion routine
|
---|
557 | * Variables :
|
---|
558 | * Result : TRUE / FALSE
|
---|
559 | * Remark :
|
---|
560 | * Status : UNTESTED STUB
|
---|
561 | *
|
---|
562 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
563 | *****************************************************************************/
|
---|
564 |
|
---|
565 | ODINFUNCTION5(BOOL, WriteFileEx,
|
---|
566 | HANDLE, hFile,
|
---|
567 | LPVOID, lpBuffer,
|
---|
568 | DWORD, nNumberOfBytesToWrite,
|
---|
569 | LPOVERLAPPED, lpOverlapped,
|
---|
570 | LPOVERLAPPED_COMPLETION_ROUTINE, lpCompletionRoutine)
|
---|
571 | {
|
---|
572 | return (HMWriteFileEx(hFile,
|
---|
573 | lpBuffer,
|
---|
574 | nNumberOfBytesToWrite,
|
---|
575 | lpOverlapped, lpCompletionRoutine));
|
---|
576 | }
|
---|
577 | //******************************************************************************
|
---|
578 | //******************************************************************************
|
---|
579 | ODINFUNCTION4(DWORD, SetFilePointer,
|
---|
580 | HANDLE, hFile,
|
---|
581 | LONG, lDistanceToMove,
|
---|
582 | PLONG, lpDistanceToMoveHigh,
|
---|
583 | DWORD, dwMoveMethod)
|
---|
584 | {
|
---|
585 | return(HMSetFilePointer(hFile,
|
---|
586 | lDistanceToMove,
|
---|
587 | lpDistanceToMoveHigh,
|
---|
588 | dwMoveMethod));
|
---|
589 | }
|
---|
590 | //******************************************************************************
|
---|
591 | //******************************************************************************
|
---|
592 | ODINFUNCTION1(DWORD, GetFileAttributesA,
|
---|
593 | LPCSTR, lpszFileName)
|
---|
594 | {
|
---|
595 | DWORD rc, error;
|
---|
596 |
|
---|
597 | if((NULL!=lpszFileName) && strlen(lpszFileName)==2 && lpszFileName[1] == ':')
|
---|
598 | {
|
---|
599 | char szDrive[4];
|
---|
600 | szDrive[0] = lpszFileName[0];
|
---|
601 | szDrive[1] = lpszFileName[1];
|
---|
602 | szDrive[2] = '\\';
|
---|
603 | szDrive[3] = 0x00;
|
---|
604 | rc = O32_GetFileAttributes((LPSTR)szDrive);
|
---|
605 | }
|
---|
606 | else {
|
---|
607 | rc = O32_GetFileAttributes((LPSTR)lpszFileName);
|
---|
608 | if(rc == -1 && lpszFileName[strlen(lpszFileName)-1] != '\\') {
|
---|
609 | char *filename = (char *)alloca(strlen(lpszFileName)+2); //+2!!!!!!
|
---|
610 | strcpy(filename, lpszFileName);
|
---|
611 | strcat(filename, "\\");
|
---|
612 | rc = O32_GetFileAttributes((LPSTR)filename);
|
---|
613 | }
|
---|
614 | }
|
---|
615 | //SvL: Open32 returns FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_NORMAL for
|
---|
616 | // directories whereas NT 4 (SP6) only returns FILE_ATTRIBUTE_DIRECTORY
|
---|
617 | if(rc != -1 && (rc & FILE_ATTRIBUTE_DIRECTORY)) {
|
---|
618 | rc = FILE_ATTRIBUTE_DIRECTORY;
|
---|
619 | }
|
---|
620 |
|
---|
621 | #if 0 // need more tests, maybe there is also a better way to hide simulated b:
|
---|
622 | if(rc == -1 && lpszFileName != NULL && !strnicmp(lpszFileName, "B:", 2))
|
---|
623 | {
|
---|
624 | error = GetLastError();
|
---|
625 | if(error = ERROR_DISK_CHANGE)
|
---|
626 | SetLastError(ERROR_NOT_READY);
|
---|
627 | else
|
---|
628 | SetLastError(error);
|
---|
629 | }
|
---|
630 | #endif
|
---|
631 | dprintf(("KERNEL32: GetFileAttributes of %s returned %d\n", lpszFileName, rc));
|
---|
632 | return(rc);
|
---|
633 | }
|
---|
634 | //******************************************************************************
|
---|
635 | //******************************************************************************
|
---|
636 | ODINFUNCTION1(DWORD, GetFileAttributesW,
|
---|
637 | LPCWSTR, arg1)
|
---|
638 | {
|
---|
639 | DWORD rc;
|
---|
640 | char *astring;
|
---|
641 |
|
---|
642 | astring = UnicodeToAsciiString((LPWSTR)arg1);
|
---|
643 | rc = CALL_ODINFUNC(GetFileAttributesA)(astring);
|
---|
644 | FreeAsciiString(astring);
|
---|
645 | return(rc);
|
---|
646 | }
|
---|
647 | //******************************************************************************
|
---|
648 | //******************************************************************************
|
---|
649 | ODINFUNCTION2(BOOL, SetFileAttributesA,
|
---|
650 | LPCSTR, arg1,
|
---|
651 | DWORD, arg2)
|
---|
652 | {
|
---|
653 | dprintf(("KERNEL32: SetFileAttributes of %s\n", arg1));
|
---|
654 | return O32_SetFileAttributes(arg1, arg2);
|
---|
655 | }
|
---|
656 | //******************************************************************************
|
---|
657 | //******************************************************************************
|
---|
658 | ODINFUNCTION2(BOOL, SetFileAttributesW,
|
---|
659 | LPCWSTR, lpFileName,
|
---|
660 | DWORD, dwFileAttributes)
|
---|
661 | {
|
---|
662 | char *asciifile;
|
---|
663 | BOOL rc;
|
---|
664 |
|
---|
665 | asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
|
---|
666 | rc = O32_SetFileAttributes(asciifile, dwFileAttributes);
|
---|
667 | FreeAsciiString(asciifile);
|
---|
668 | return(rc);
|
---|
669 | }
|
---|
670 | //******************************************************************************
|
---|
671 | //******************************************************************************
|
---|
672 | ODINFUNCTION4(DWORD, GetFullPathNameA,
|
---|
673 | LPCSTR, arg1,
|
---|
674 | DWORD, arg2,
|
---|
675 | LPSTR, arg3,
|
---|
676 | LPSTR *, arg4)
|
---|
677 | {
|
---|
678 | char *ptr;
|
---|
679 | DWORD rc;
|
---|
680 | dprintf(("KERNEL32: GetFullPathName called with %s %d %x", arg1, arg2, arg3));
|
---|
681 | while((ptr = strchr(arg1, '/')) != NULL)
|
---|
682 | *ptr = '\\';
|
---|
683 |
|
---|
684 | return O32_GetFullPathName(arg1, arg2, arg3, arg4);
|
---|
685 | }
|
---|
686 | //******************************************************************************
|
---|
687 | //******************************************************************************
|
---|
688 | ODINFUNCTION4(DWORD, GetFullPathNameW,
|
---|
689 | LPCWSTR, lpFileName,
|
---|
690 | DWORD, nBufferLength,
|
---|
691 | LPWSTR, lpBuffer,
|
---|
692 | LPWSTR *, lpFilePart)
|
---|
693 | {
|
---|
694 | char *astring, *asciibuffer, *asciipart;
|
---|
695 | DWORD rc;
|
---|
696 |
|
---|
697 | asciibuffer = (char *)malloc(nBufferLength+1);
|
---|
698 | astring = UnicodeToAsciiString((LPWSTR)lpFileName);
|
---|
699 |
|
---|
700 | rc = CALL_ODINFUNC(GetFullPathNameA)(astring,
|
---|
701 | nBufferLength,
|
---|
702 | asciibuffer,
|
---|
703 | &asciipart);
|
---|
704 |
|
---|
705 | dprintf(("KERNEL32: GetFullPathNameW %s returns %s\n",
|
---|
706 | astring,
|
---|
707 | asciibuffer));
|
---|
708 |
|
---|
709 | if(rc)
|
---|
710 | AsciiToUnicode(asciibuffer,
|
---|
711 | lpBuffer);
|
---|
712 |
|
---|
713 | if(lpFilePart) {
|
---|
714 | if (asciipart == NULL)
|
---|
715 | *lpFilePart = NULL;
|
---|
716 | else
|
---|
717 | *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
|
---|
718 | }
|
---|
719 |
|
---|
720 | FreeAsciiString(astring);
|
---|
721 | free(asciibuffer);
|
---|
722 | return(rc);
|
---|
723 | }
|
---|
724 | //******************************************************************************
|
---|
725 | //******************************************************************************
|
---|
726 | ODINFUNCTION5(BOOL, LockFile,
|
---|
727 | HANDLE, arg1,
|
---|
728 | DWORD, arg2,
|
---|
729 | DWORD, arg3,
|
---|
730 | DWORD, arg4,
|
---|
731 | DWORD, arg5)
|
---|
732 | {
|
---|
733 | return HMLockFile(arg1,
|
---|
734 | arg2,
|
---|
735 | arg3,
|
---|
736 | arg4,
|
---|
737 | arg5);
|
---|
738 | }
|
---|
739 |
|
---|
740 |
|
---|
741 | /*****************************************************************************
|
---|
742 | * Name : BOOL LockFileEx
|
---|
743 | * Purpose : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
|
---|
744 | * Parameters: HANDLE hFile handle of file to lock
|
---|
745 | * DWORD dwFlags functional behavior modification flags
|
---|
746 | * DWORD dwReserved reserved, must be set to zero
|
---|
747 | * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
|
---|
748 | * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
|
---|
749 | * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
|
---|
750 | * Variables :
|
---|
751 | * Result : TRUE / FALSE
|
---|
752 | * Remark :
|
---|
753 | * Status : UNTESTED STUB
|
---|
754 | *
|
---|
755 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
756 | *****************************************************************************/
|
---|
757 |
|
---|
758 | ODINFUNCTION6(BOOL, LockFileEx,
|
---|
759 | HANDLE, hFile,
|
---|
760 | DWORD, dwFlags,
|
---|
761 | DWORD, dwReserved,
|
---|
762 | DWORD, nNumberOfBytesToLockLow,
|
---|
763 | DWORD, nNumberOfBytesToLockHigh,
|
---|
764 | LPOVERLAPPED, lpOverlapped)
|
---|
765 | {
|
---|
766 | return(HMLockFile(hFile,
|
---|
767 | lpOverlapped->Offset,
|
---|
768 | lpOverlapped->OffsetHigh,
|
---|
769 | nNumberOfBytesToLockLow,
|
---|
770 | nNumberOfBytesToLockHigh));
|
---|
771 | }
|
---|
772 |
|
---|
773 |
|
---|
774 |
|
---|
775 |
|
---|
776 | //******************************************************************************
|
---|
777 | //******************************************************************************
|
---|
778 | ODINFUNCTION2(BOOL, MoveFileA,
|
---|
779 | LPCSTR, arg1,
|
---|
780 | LPCSTR, arg2)
|
---|
781 | {
|
---|
782 | dprintf(("KERNEL32: MoveFileA %s %s", arg1, arg2));
|
---|
783 | return O32_MoveFile(arg1, arg2);
|
---|
784 | }
|
---|
785 | //******************************************************************************
|
---|
786 | //******************************************************************************
|
---|
787 | ODINFUNCTION3(BOOL, MoveFileExA,
|
---|
788 | LPCSTR, arg1,
|
---|
789 | LPCSTR, arg2,
|
---|
790 | DWORD, fdwFlags)
|
---|
791 | {
|
---|
792 | dprintf(("KERNEL32: MoveFileExA %s to %s, not complete!\n", arg1, arg2));
|
---|
793 | return O32_MoveFile(arg1, arg2);
|
---|
794 | }
|
---|
795 | //******************************************************************************
|
---|
796 | //******************************************************************************
|
---|
797 | ODINFUNCTION2(BOOL, MoveFileW,
|
---|
798 | LPCWSTR, lpSrc,
|
---|
799 | LPCWSTR, lpDest)
|
---|
800 | {
|
---|
801 | char *asciisrc, *asciidest;
|
---|
802 | BOOL rc;
|
---|
803 |
|
---|
804 | asciisrc = UnicodeToAsciiString((LPWSTR)lpSrc);
|
---|
805 | asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
|
---|
806 | rc = O32_MoveFile(asciisrc, asciidest);
|
---|
807 | FreeAsciiString(asciisrc);
|
---|
808 | FreeAsciiString(asciidest);
|
---|
809 | return(rc);
|
---|
810 | }
|
---|
811 | //******************************************************************************
|
---|
812 | //******************************************************************************
|
---|
813 | ODINFUNCTION3(BOOL, MoveFileExW,
|
---|
814 | LPCWSTR, arg1,
|
---|
815 | LPCWSTR, arg2,
|
---|
816 | DWORD, fdwFlags)
|
---|
817 | {
|
---|
818 | dprintf(("KERNEL32: MoveFileExW %s to %s, not complete!\n", arg1, arg2));
|
---|
819 | return MoveFileW(arg1, arg2);
|
---|
820 | }
|
---|
821 | //******************************************************************************
|
---|
822 | /*****************************************************************************
|
---|
823 | ODINFUNCTION3(*, :,
|
---|
824 | HFILE, WIN32API,
|
---|
825 | OpenFile *, Purpose,
|
---|
826 | :, forwardOpenFile to Open32
|
---|
827 | * Parameters:
|
---|
828 | * Variables :
|
---|
829 | * Result : API returncode
|
---|
830 | * Remark : modified for handle translation support
|
---|
831 | * Status : @@@PH verify if 0 is a valid "invalid handle" :)
|
---|
832 | *
|
---|
833 | * Author : Patrick Haller [Fri, 1998/06/12 02:53]
|
---|
834 | *****************************************************************************/
|
---|
835 |
|
---|
836 | ODINFUNCTION3(HFILE, OpenFile,
|
---|
837 | LPCSTR, lpszFile,
|
---|
838 | OFSTRUCT *, lpOpenBuff,
|
---|
839 | UINT, fuMode)
|
---|
840 | {
|
---|
841 | HFILE hFile;
|
---|
842 |
|
---|
843 | dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
|
---|
844 | lpszFile,
|
---|
845 | lpOpenBuff,
|
---|
846 | fuMode));
|
---|
847 |
|
---|
848 | hFile = HMOpenFile(lpszFile, /* call open32 */
|
---|
849 | lpOpenBuff,
|
---|
850 | fuMode);
|
---|
851 |
|
---|
852 | return (hFile);
|
---|
853 | }
|
---|
854 | //******************************************************************************
|
---|
855 | //******************************************************************************
|
---|
856 | ODINFUNCTION5(BOOL, UnlockFile,
|
---|
857 | HANDLE, arg1,
|
---|
858 | DWORD, arg2,
|
---|
859 | DWORD, arg3,
|
---|
860 | DWORD, arg4,
|
---|
861 | DWORD, arg5)
|
---|
862 | {
|
---|
863 | return HMUnlockFile(arg1,
|
---|
864 | arg2,
|
---|
865 | arg3,
|
---|
866 | arg4,
|
---|
867 | arg5);
|
---|
868 | }
|
---|
869 |
|
---|
870 |
|
---|
871 | /*****************************************************************************
|
---|
872 | * Name : BOOL UnlockFileEx
|
---|
873 | * Purpose : The UnlockFileEx function unlocks a previously locked byte range in an open file.
|
---|
874 | * Parameters: HANDLE hFile handle of file to lock
|
---|
875 | * DWORD dwReserved reserved, must be set to zero
|
---|
876 | * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
|
---|
877 | * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
|
---|
878 | * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
|
---|
879 | * Variables :
|
---|
880 | * Result : TRUE / FALSE
|
---|
881 | * Remark :
|
---|
882 | * Status : UNTESTED STUB
|
---|
883 | *
|
---|
884 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
885 | *****************************************************************************/
|
---|
886 |
|
---|
887 | ODINFUNCTION5(BOOL, UnlockFileEx,
|
---|
888 | HANDLE, hFile,
|
---|
889 | DWORD, dwReserved,
|
---|
890 | DWORD, nNumberOfBytesToLockLow,
|
---|
891 | DWORD, nNumberOfBytesToLockHigh,
|
---|
892 | LPOVERLAPPED, lpOverlapped)
|
---|
893 | {
|
---|
894 | return(HMUnlockFileEx(hFile, dwReserved,
|
---|
895 | nNumberOfBytesToLockLow,
|
---|
896 | nNumberOfBytesToLockHigh,
|
---|
897 | lpOverlapped));
|
---|
898 | }
|
---|
899 | //******************************************************************************
|
---|
900 | //Behaviour in NT 4, SP6:
|
---|
901 | //- converts long filename to 8.3 short filname (TODO: not yet done here!)
|
---|
902 | //- fails on volume that doesn't support 8.3 filenames
|
---|
903 | //- if lpszShortPath 0 or cchBuffer too small -> return required length
|
---|
904 | // (INCLUDING 0 terminator)
|
---|
905 | //- if lpszLongPath == NULL -> ERROR_INVALID_PARAMETER (return 0)
|
---|
906 | //- if lpszLongPath empty -> proceed as if nothing is wrong
|
---|
907 | //- does NOT clear the last error if successful!
|
---|
908 | //- if successful -> return length of string (excluding 0 terminator)
|
---|
909 | //******************************************************************************
|
---|
910 | ODINFUNCTION3(DWORD, GetShortPathNameA,
|
---|
911 | LPCTSTR, lpszLongPath,
|
---|
912 | LPTSTR, lpszShortPath,
|
---|
913 | DWORD, cchBuffer)
|
---|
914 | {
|
---|
915 | int length;
|
---|
916 |
|
---|
917 | dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it", lpszLongPath));
|
---|
918 |
|
---|
919 | if(!lpszLongPath) {
|
---|
920 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
921 | return 0;
|
---|
922 | }
|
---|
923 |
|
---|
924 | length = lstrlenA(lpszLongPath) + 1;
|
---|
925 | if(length > cchBuffer) {
|
---|
926 | if(lpszShortPath) {
|
---|
927 | *lpszShortPath = 0;
|
---|
928 | }
|
---|
929 | return(length); //return length required (including 0 terminator)
|
---|
930 | }
|
---|
931 | lstrcpyA(lpszShortPath, lpszLongPath);
|
---|
932 | return(length-1);
|
---|
933 | }
|
---|
934 | //******************************************************************************
|
---|
935 | //******************************************************************************
|
---|
936 | ODINFUNCTION3(DWORD, GetShortPathNameW,
|
---|
937 | LPCWSTR, lpszLongPath,
|
---|
938 | LPWSTR, lpszShortPath,
|
---|
939 | DWORD, cchBuffer)
|
---|
940 | {
|
---|
941 | int length;
|
---|
942 |
|
---|
943 | dprintf(("KERNEL32: GetShortPathNameW; just copying it"));
|
---|
944 | if(!lpszLongPath) {
|
---|
945 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
946 | return 0;
|
---|
947 | }
|
---|
948 |
|
---|
949 | length = lstrlenW(lpszLongPath) + 1;
|
---|
950 | if(length > cchBuffer) {
|
---|
951 | if(lpszShortPath) {
|
---|
952 | *lpszShortPath = 0;
|
---|
953 | }
|
---|
954 | return(length); //return length required (including 0 terminator)
|
---|
955 | }
|
---|
956 | lstrcpyW(lpszShortPath, lpszLongPath);
|
---|
957 | return(length-1);
|
---|
958 | }
|
---|
959 | //******************************************************************************
|
---|
960 | //Behaviour in NT 4, SP6: (presumably the same as GetShortPathNameA; TODO check)
|
---|
961 | //- converts short filename to long filenames (TODO: not yet done here!)
|
---|
962 | //- if lpszShortPath 0 or cchBuffer too small -> return required length
|
---|
963 | // (INCLUDING 0 terminator)
|
---|
964 | //- if lpszLongPath == NULL -> ERROR_INVALID_PARAMETER (return 0)
|
---|
965 | //- if lpszLongPath empty -> proceed as if nothing is wrong
|
---|
966 | //- does NOT clear the last error if successful!
|
---|
967 | //- if successful -> return length of string (excluding 0 terminator)
|
---|
968 | //******************************************************************************
|
---|
969 | DWORD WINAPI GetLongPathNameA( LPCSTR lpszShortPath, LPSTR lpszLongPath,
|
---|
970 | DWORD cchBuffer )
|
---|
971 | {
|
---|
972 | int length;
|
---|
973 |
|
---|
974 | dprintf(("GetLongPathNameA %x %s %d", lpszShortPath, lpszLongPath, cchBuffer));
|
---|
975 |
|
---|
976 | if(!lpszShortPath) {
|
---|
977 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
978 | return 0;
|
---|
979 | }
|
---|
980 |
|
---|
981 | length = lstrlenA(lpszShortPath) + 1;
|
---|
982 | if(length > cchBuffer) {
|
---|
983 | if(lpszLongPath) {
|
---|
984 | *lpszLongPath = 0;
|
---|
985 | }
|
---|
986 | return(length); //return length required (including 0 terminator)
|
---|
987 | }
|
---|
988 | lstrcpyA(lpszLongPath, lpszShortPath);
|
---|
989 | return(length-1);
|
---|
990 | }
|
---|
991 | //******************************************************************************
|
---|
992 | //******************************************************************************
|
---|
993 | DWORD WINAPI GetLongPathNameW( LPCWSTR lpszShortPath, LPWSTR lpszLongPath,
|
---|
994 | DWORD cchBuffer )
|
---|
995 | {
|
---|
996 | int length;
|
---|
997 |
|
---|
998 | dprintf(("GetLongPathNameW %x %ls %d", lpszShortPath, lpszLongPath, cchBuffer));
|
---|
999 |
|
---|
1000 | if(!lpszShortPath) {
|
---|
1001 | SetLastError(ERROR_INVALID_PARAMETER);
|
---|
1002 | return 0;
|
---|
1003 | }
|
---|
1004 |
|
---|
1005 | length = lstrlenW(lpszShortPath) + 1;
|
---|
1006 | if(length > cchBuffer) {
|
---|
1007 | if(lpszLongPath) {
|
---|
1008 | *lpszLongPath = 0;
|
---|
1009 | }
|
---|
1010 | return(length); //return length required (including 0 terminator)
|
---|
1011 | }
|
---|
1012 | lstrcpyW(lpszLongPath, lpszShortPath);
|
---|
1013 | return(length-1);
|
---|
1014 | }
|
---|
1015 | //******************************************************************************
|
---|
1016 | //******************************************************************************
|
---|
1017 | ODINPROCEDURE0(SetFileApisToANSI)
|
---|
1018 | {
|
---|
1019 | dprintf(("SetFileApisToANSI() stub\n"));
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 | /*****************************************************************************
|
---|
1023 | * Name : DWORD GetCompressedFileSizeA
|
---|
1024 | * Purpose : The GetCompressedFileSizeA function obtains the compressed
|
---|
1025 | * size, in bytes, of a specified file.
|
---|
1026 | * Parameters: LPCTSTR lpFileName, // pointer to name of file
|
---|
1027 | * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
|
---|
1028 | * high-order doubleword of file size
|
---|
1029 | * Variables :
|
---|
1030 | * Result : size of compressed file
|
---|
1031 | * Remark :
|
---|
1032 | * Status : UNTESTED
|
---|
1033 | *
|
---|
1034 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
1035 | *****************************************************************************/
|
---|
1036 |
|
---|
1037 | ODINFUNCTION2(DWORD, GetCompressedFileSizeA,
|
---|
1038 | LPCTSTR, lpFileName,
|
---|
1039 | LPDWORD, lpFileSizeHigh)
|
---|
1040 | {
|
---|
1041 | dprintf(("KERNEL32: GetCompressedFileSizeA (%s, %08xh) not implemented.\n",
|
---|
1042 | lpFileName,
|
---|
1043 | lpFileSizeHigh));
|
---|
1044 |
|
---|
1045 | /* @@@PH: simply return the standard filesize */
|
---|
1046 | return 0;
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 |
|
---|
1050 | /*****************************************************************************
|
---|
1051 | * Name : DWORD GetCompressedFileSizeW
|
---|
1052 | * Purpose : The GetCompressedFileSizeE function obtains the compressed
|
---|
1053 | * size, in bytes, of a specified file.
|
---|
1054 | * Parameters: LPCWSTR lpFileName, // pointer to name of file
|
---|
1055 | * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
|
---|
1056 | * high-order doubleword of file size
|
---|
1057 | * Variables :
|
---|
1058 | * Result : size of compressed file
|
---|
1059 | * Remark :
|
---|
1060 | * Status : UNTESTED
|
---|
1061 | *
|
---|
1062 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
1063 | *****************************************************************************/
|
---|
1064 |
|
---|
1065 | ODINFUNCTION2(DWORD, GetCompressedFileSizeW,
|
---|
1066 | LPCWSTR, lpFileName,
|
---|
1067 | LPDWORD, lpFileSizeHigh)
|
---|
1068 | {
|
---|
1069 | LPCTSTR lpAsciiFileName; /* converted filename */
|
---|
1070 | DWORD rc; /* function result */
|
---|
1071 |
|
---|
1072 | dprintf(("KERNEL32: GetCompressedFileSizeW (%s, %08xh)\n",
|
---|
1073 | lpFileName,
|
---|
1074 | lpFileSizeHigh));
|
---|
1075 |
|
---|
1076 | lpAsciiFileName = UnicodeToAsciiString( (LPWSTR) lpFileName);
|
---|
1077 |
|
---|
1078 | rc = GetCompressedFileSizeA(lpAsciiFileName,
|
---|
1079 | lpFileSizeHigh);
|
---|
1080 |
|
---|
1081 | FreeAsciiString( (char *) lpAsciiFileName);
|
---|
1082 |
|
---|
1083 | return (rc); /* return result */
|
---|
1084 | }
|
---|
1085 |
|
---|
1086 |
|
---|
1087 | /*****************************************************************************
|
---|
1088 | * Name : BOOL GetFileAttributesExA
|
---|
1089 | * Purpose :
|
---|
1090 | * Parameters:
|
---|
1091 | * Variables :
|
---|
1092 | * Result :
|
---|
1093 | * Remark : KERNEL32.874
|
---|
1094 | * Status : UNTESTED
|
---|
1095 | *
|
---|
1096 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
1097 | *****************************************************************************/
|
---|
1098 |
|
---|
1099 | ODINFUNCTION3(BOOL, GetFileAttributesExA,
|
---|
1100 | LPCSTR, lpFileName,
|
---|
1101 | GET_FILEEX_INFO_LEVELS, fInfoLevelId,
|
---|
1102 | LPVOID, lpFileInformation)
|
---|
1103 | {
|
---|
1104 | BOOL rc;
|
---|
1105 |
|
---|
1106 | dprintf(("KERNEL32: GetFileAttributesExA(%s,%08xh,%08xh) mostly implemented.\n",
|
---|
1107 | lpFileName,
|
---|
1108 | fInfoLevelId,
|
---|
1109 | lpFileInformation));
|
---|
1110 |
|
---|
1111 | if (lpFileName == NULL) return FALSE;
|
---|
1112 | if (lpFileInformation == NULL) return FALSE;
|
---|
1113 |
|
---|
1114 | if (fInfoLevelId == GetFileExInfoStandard)
|
---|
1115 | {
|
---|
1116 | LPWIN32_FILE_ATTRIBUTE_DATA lpFad = (LPWIN32_FILE_ATTRIBUTE_DATA) lpFileInformation;
|
---|
1117 |
|
---|
1118 | rc = OSLibDosGetFileAttributesEx((LPSTR)lpFileName,
|
---|
1119 | fInfoLevelId,
|
---|
1120 | lpFileInformation);
|
---|
1121 | return (rc);
|
---|
1122 | }
|
---|
1123 | else
|
---|
1124 | {
|
---|
1125 | dprintf(("KERNEL32: GetFileAttributesExA - invalid info level %d!\n",
|
---|
1126 | fInfoLevelId));
|
---|
1127 | return FALSE;
|
---|
1128 | }
|
---|
1129 | }
|
---|
1130 |
|
---|
1131 |
|
---|
1132 | /*****************************************************************************
|
---|
1133 | * Name : BOOL GetFileAttributesExW
|
---|
1134 | * Purpose :
|
---|
1135 | * Parameters:
|
---|
1136 | * Variables :
|
---|
1137 | * Result :
|
---|
1138 | * Remark : KERNEL32.875
|
---|
1139 | * Status : UNTESTED
|
---|
1140 | *
|
---|
1141 | * Author : Patrick Haller [Mon, 1998/06/15 08:00]
|
---|
1142 | *****************************************************************************/
|
---|
1143 |
|
---|
1144 | ODINFUNCTION3(BOOL, GetFileAttributesExW,
|
---|
1145 | LPCWSTR, lpFileName,
|
---|
1146 | GET_FILEEX_INFO_LEVELS, fInfoLevelId,
|
---|
1147 | LPVOID, lpFileInformation)
|
---|
1148 | {
|
---|
1149 | LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
|
---|
1150 | BOOL res = GetFileAttributesExA( nameA, fInfoLevelId, lpFileInformation);
|
---|
1151 | HeapFree( GetProcessHeap(), 0, nameA );
|
---|
1152 | return res;
|
---|
1153 | }
|
---|
1154 |
|
---|
1155 | //******************************************************************************
|
---|
1156 | //******************************************************************************
|
---|
1157 | ODINFUNCTION3(HANDLE, FindFirstChangeNotificationA,
|
---|
1158 | LPCSTR, lpPathName,
|
---|
1159 | BOOL, bWatchSubtree,
|
---|
1160 | DWORD, dwNotifyFilter)
|
---|
1161 | {
|
---|
1162 | dprintf(("KERNEL32: FindFirstChangeNotificationA, Not implemented (faked)\n"));
|
---|
1163 | return -1;
|
---|
1164 | }
|
---|
1165 | //******************************************************************************
|
---|
1166 | //******************************************************************************
|
---|
1167 | ODINFUNCTION1(BOOL, FindNextChangeNotification,
|
---|
1168 | HANDLE, hChange)
|
---|
1169 | {
|
---|
1170 | dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
|
---|
1171 | hChange));
|
---|
1172 |
|
---|
1173 | return FALSE;
|
---|
1174 | }
|
---|
1175 | //******************************************************************************
|
---|
1176 | //******************************************************************************
|
---|
1177 | ODINFUNCTION1(BOOL, FindCloseChangeNotification, HANDLE, hChange)
|
---|
1178 | {
|
---|
1179 | dprintf(("KERNEL32: OS2FindNextChangeNotification, Not implemented\n"));
|
---|
1180 |
|
---|
1181 | return(TRUE);
|
---|
1182 | }
|
---|
1183 | /*****************************************************************************
|
---|
1184 | * Name : HANDLE WIN32API FindFirstChangeNotificationW
|
---|
1185 | * Purpose : The FindFirstChangeNotification function creates a change
|
---|
1186 | * notification handle and sets up initial change notification
|
---|
1187 | * filter conditions. A wait on a notification handle succeeds when
|
---|
1188 | * a change matching the filter conditions occurs in the specified
|
---|
1189 | * directory or subtree.
|
---|
1190 | * Parameters: LPCWSTR lpPathName pointer to name of directory to watch
|
---|
1191 | * BOOL bWatchSubtree flag for monitoring directory or
|
---|
1192 | * directory tree
|
---|
1193 | * DWORD dwNotifyFilter filter conditions to watch for
|
---|
1194 | * Variables :
|
---|
1195 | * Result : If the function succeeds, the return value is a handle to a find
|
---|
1196 | * change notification object.
|
---|
1197 | * If the function fails, the return value is INVALID_HANDLE_VALUE
|
---|
1198 | * Remark :
|
---|
1199 | * Status : UNTESTED STUB
|
---|
1200 | *
|
---|
1201 | * Author : Markus Montkowski [Tha, 1998/05/21 20:57]
|
---|
1202 | *****************************************************************************/
|
---|
1203 | ODINFUNCTION3(HANDLE, FindFirstChangeNotificationW, LPCWSTR, lpPathName,
|
---|
1204 | BOOL, bWatchSubtree,
|
---|
1205 | DWORD, dwNotifyFilter)
|
---|
1206 | {
|
---|
1207 | LPSTR lpAsciiPath;
|
---|
1208 | HANDLE hChange;
|
---|
1209 |
|
---|
1210 | lpAsciiPath = UnicodeToAsciiString( (LPWSTR) lpPathName);
|
---|
1211 | hChange = FindFirstChangeNotificationA(lpAsciiPath, bWatchSubtree,
|
---|
1212 | dwNotifyFilter );
|
---|
1213 | if (lpAsciiPath) FreeAsciiString(lpAsciiPath);
|
---|
1214 | return hChange;
|
---|
1215 | }
|
---|
1216 | //******************************************************************************
|
---|
1217 | //******************************************************************************
|
---|
1218 | ODINFUNCTION8(BOOL, DeviceIoControl, HANDLE, hDevice, DWORD, dwIoControlCode,
|
---|
1219 | LPVOID, lpInBuffer, DWORD, nInBufferSize,
|
---|
1220 | LPVOID, lpOutBuffer, DWORD, nOutBufferSize,
|
---|
1221 | LPDWORD, lpBytesReturned, LPOVERLAPPED, lpOverlapped)
|
---|
1222 | {
|
---|
1223 | return HMDeviceIoControl(hDevice, dwIoControlCode, lpInBuffer, nInBufferSize,
|
---|
1224 | lpOutBuffer, nOutBufferSize, lpBytesReturned, lpOverlapped);
|
---|
1225 | }
|
---|
1226 | //******************************************************************************
|
---|
1227 | //******************************************************************************
|
---|