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