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