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