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