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