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