source: trunk/src/kernel32/Fileio.cpp@ 1570

Last change on this file since 1570 was 1570, checked in by phaller, 26 years ago

Fix: undocumented behaviour in SearchPathA and bugfix in SearchPathW

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