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

Last change on this file since 1481 was 1481, checked in by sandervl, 26 years ago

WinExec rewrite + mmap bugfixes

File size: 30.1 KB
Line 
1/* $Id: Fileio.cpp,v 1.12 1999-10-27 18:11:38 sandervl Exp $ */
2
3/*
4 * Win32 File IO API functions for OS/2
5 *
6 * Copyright 1998 Sander van Leeuwen
7 * Copyright 1998 Patrick Haller
8 *
9 *
10 * Project Odin Software License can be found in LICENSE.TXT
11 *
12 */
13
14
15/*****************************************************************************
16 * Includes *
17 *****************************************************************************/
18
19#include <odin.h>
20#include <odinwrap.h>
21#include <os2sel.h>
22
23#include <os2win.h>
24#include <stdlib.h>
25#include <string.h>
26#include "unicode.h"
27#include <heapstring.h>
28#include "handlemanager.h"
29#include "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, arg1,
367 LPCSTR, arg2,
368 LPCSTR, arg3,
369 DWORD, arg4,
370 LPSTR, arg5,
371 LPSTR *, arg6)
372{
373 dprintf(("KERNEL32: SearchPathA\n"));
374 return O32_SearchPath(arg1, arg2, arg3, arg4, arg5, arg6);
375}
376//******************************************************************************
377//******************************************************************************
378ODINFUNCTION6(DWORD, SearchPathW,
379 LPCWSTR, lpPath,
380 LPCWSTR, lpFileName,
381 LPCWSTR, lpExtension,
382 DWORD, nBufferLength,
383 LPWSTR, lpBuffer,
384 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//******************************************************************************
408ODINFUNCTION1(DWORD, GetFileAttributesA,
409 LPCSTR, lpszFileName)
410{
411 DWORD rc, error;
412
413 rc = O32_GetFileAttributes((LPSTR)lpszFileName);
414#if 0 // need more tests, maybe there is also a better way to hide simulated b:
415 if(rc == -1 && lpszFileName != NULL && !strnicmp(lpszFileName, "B:", 2))
416 {
417 error = GetLastError();
418 if(error = ERROR_DISK_CHANGE)
419 SetLastError(ERROR_NOT_READY);
420 else
421 SetLastError(error);
422 }
423#endif
424 dprintf(("KERNEL32: GetFileAttributes of %s returned %d\n", lpszFileName, rc));
425 return(rc);
426}
427//******************************************************************************
428//******************************************************************************
429ODINFUNCTION1(DWORD, GetFileAttributesW,
430 LPCWSTR, arg1)
431{
432 DWORD rc;
433 char *astring;
434
435 dprintf(("KERNEL32: GetFileAttributesW\n"));
436 astring = UnicodeToAsciiString((LPWSTR)arg1);
437 rc = O32_GetFileAttributes(astring);
438 FreeAsciiString(astring);
439 return(rc);
440}
441//******************************************************************************
442//******************************************************************************
443ODINFUNCTION2(BOOL, SetFileAttributesA,
444 LPCSTR, arg1,
445 DWORD, arg2)
446{
447 dprintf(("KERNEL32: SetFileAttributes of %s\n", arg1));
448 return O32_SetFileAttributes(arg1, arg2);
449}
450//******************************************************************************
451//******************************************************************************
452ODINFUNCTION2(BOOL, SetFileAttributesW,
453 LPCWSTR, lpFileName,
454 DWORD, dwFileAttributes)
455{
456 char *asciifile;
457 BOOL rc;
458
459 dprintf(("KERNEL32: SetFileAttributesW\n"));
460 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
461 rc = O32_SetFileAttributes(asciifile, dwFileAttributes);
462 FreeAsciiString(asciifile);
463 return(rc);
464}
465//******************************************************************************
466//******************************************************************************
467ODINFUNCTION4(DWORD, GetFullPathNameA,
468 LPCSTR, arg1,
469 DWORD, arg2,
470 LPSTR, arg3,
471 LPSTR *, arg4)
472{
473 dprintf(("KERNEL32: GetFullPathName %s\n", arg1));
474 return O32_GetFullPathName(arg1, arg2, arg3, arg4);
475}
476//******************************************************************************
477//******************************************************************************
478ODINFUNCTION4(DWORD, GetFullPathNameW,
479 LPCWSTR, lpFileName,
480 DWORD, nBufferLength,
481 LPWSTR, lpBuffer,
482 LPWSTR *, lpFilePart)
483{
484 char *astring, *asciibuffer, *asciipart;
485 DWORD rc;
486
487 dprintf(("KERNEL32: GetFullPathNameW\n"));
488 asciibuffer = (char *)malloc(nBufferLength+1);
489 astring = UnicodeToAsciiString((LPWSTR)lpFileName);
490
491 rc = O32_GetFullPathName(astring,
492 nBufferLength,
493 asciibuffer,
494 &asciipart);
495
496 dprintf(("KERNEL32: GetFullPathNameW %s returns %s\n",
497 astring,
498 asciibuffer));
499
500 if(rc)
501 AsciiToUnicode(asciibuffer,
502 lpBuffer);
503
504 if(lpFilePart)
505 *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
506
507 FreeAsciiString(astring);
508 free(asciibuffer);
509 return(rc);
510}
511//******************************************************************************
512//******************************************************************************
513ODINFUNCTION5(BOOL, LockFile,
514 HANDLE, arg1,
515 DWORD, arg2,
516 DWORD, arg3,
517 DWORD, arg4,
518 DWORD, arg5)
519{
520 dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n",
521 arg1,
522 arg2,
523 arg3,
524 arg4,
525 arg5));
526
527 return HMLockFile(arg1,
528 arg2,
529 arg3,
530 arg4,
531 arg5);
532}
533
534
535/*****************************************************************************
536 * Name : BOOL LockFileEx
537 * Purpose : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
538 * Parameters: HANDLE hFile handle of file to lock
539 * DWORD dwFlags functional behavior modification flags
540 * DWORD dwReserved reserved, must be set to zero
541 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
542 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
543 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
544 * Variables :
545 * Result : TRUE / FALSE
546 * Remark :
547 * Status : UNTESTED STUB
548 *
549 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
550 *****************************************************************************/
551
552ODINFUNCTION6(BOOL, LockFileEx,
553 HANDLE, hFile,
554 DWORD, dwFlags,
555 DWORD, dwReserved,
556 DWORD, nNumberOfBytesToLockLow,
557 DWORD, nNumberOfBytesToLockHigh,
558 LPOVERLAPPED, lpOverlapped)
559{
560 dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
561 hFile,
562 dwFlags,
563 dwReserved,
564 nNumberOfBytesToLockLow,
565 nNumberOfBytesToLockHigh,
566 lpOverlapped));
567
568 return(HMLockFile(hFile,
569 lpOverlapped->Offset,
570 lpOverlapped->OffsetHigh,
571 nNumberOfBytesToLockLow,
572 nNumberOfBytesToLockHigh));
573}
574
575
576
577
578//******************************************************************************
579//******************************************************************************
580ODINFUNCTION2(BOOL, MoveFileA,
581 LPCSTR, arg1,
582 LPCSTR, arg2)
583{
584 dprintf(("KERNEL32: MoveFileA\n"));
585 return O32_MoveFile(arg1, arg2);
586}
587//******************************************************************************
588//******************************************************************************
589ODINFUNCTION3(BOOL, MoveFileExA,
590 LPCSTR, arg1,
591 LPCSTR, arg2,
592 DWORD, fdwFlags)
593{
594 dprintf(("KERNEL32: MoveFileExA %s to %s, not complete!\n", arg1, arg2));
595 return O32_MoveFile(arg1, arg2);
596}
597//******************************************************************************
598//******************************************************************************
599ODINFUNCTION2(BOOL, MoveFileW,
600 LPCWSTR, lpSrc,
601 LPCWSTR, lpDest)
602{
603 char *asciisrc, *asciidest;
604 BOOL rc;
605
606 dprintf(("KERNEL32: MoveFileW\n"));
607 asciisrc = UnicodeToAsciiString((LPWSTR)lpSrc);
608 asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
609 rc = O32_MoveFile(asciisrc, asciidest);
610 FreeAsciiString(asciisrc);
611 FreeAsciiString(asciidest);
612 return(rc);
613}
614//******************************************************************************
615//******************************************************************************
616ODINFUNCTION3(BOOL, MoveFileExW,
617 LPCWSTR, arg1,
618 LPCWSTR, arg2,
619 DWORD, fdwFlags)
620{
621 dprintf(("KERNEL32: MoveFileExW %s to %s, not complete!\n", arg1, arg2));
622 return MoveFileW(arg1, arg2);
623}
624//******************************************************************************
625/*****************************************************************************
626ODINFUNCTION3(*, :,
627 HFILE, WIN32API,
628 OpenFile *, Purpose,
629 :, forwardOpenFile to Open32
630 * Parameters:
631 * Variables :
632 * Result : API returncode
633 * Remark : modified for handle translation support
634 * Status : @@@PH verify if 0 is a valid "invalid handle" :)
635 *
636 * Author : Patrick Haller [Fri, 1998/06/12 02:53]
637 *****************************************************************************/
638
639ODINFUNCTION3(HFILE, OpenFile,
640 LPCSTR, arg1,
641 OFSTRUCT *, arg2,
642 UINT, arg3)
643{
644 HFILE hFile;
645
646 dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
647 arg1,
648 arg2,
649 arg3));
650
651 hFile = HMOpenFile(arg1, /* call open32 */
652 arg2,
653 arg3);
654
655 return (hFile);
656}
657//******************************************************************************
658//******************************************************************************
659ODINFUNCTION5(BOOL, UnlockFile,
660 HANDLE, arg1,
661 DWORD, arg2,
662 DWORD, arg3,
663 DWORD, arg4,
664 DWORD, arg5)
665{
666 dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
667 arg1,
668 arg2,
669 arg3,
670 arg4,
671 arg5));
672
673 return HMUnlockFile(arg1,
674 arg2,
675 arg3,
676 arg4,
677 arg5);
678}
679
680
681/*****************************************************************************
682 * Name : BOOL UnlockFileEx
683 * Purpose : The UnlockFileEx function unlocks a previously locked byte range in an open file.
684 * Parameters: HANDLE hFile handle of file to lock
685 * DWORD dwReserved reserved, must be set to zero
686 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
687 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
688 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
689 * Variables :
690 * Result : TRUE / FALSE
691 * Remark :
692 * Status : UNTESTED STUB
693 *
694 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
695 *****************************************************************************/
696
697ODINFUNCTION5(BOOL, UnlockFileEx,
698 HANDLE, hFile,
699 DWORD, dwReserved,
700 DWORD, nNumberOfBytesToLockLow,
701 DWORD, nNumberOfBytesToLockHigh,
702 LPOVERLAPPED, lpOverlapped)
703{
704 dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
705 hFile,
706 dwReserved,
707 nNumberOfBytesToLockLow,
708 nNumberOfBytesToLockHigh,
709 lpOverlapped));
710
711 return(HMUnlockFile(hFile,
712 lpOverlapped->Offset,
713 lpOverlapped->OffsetHigh,
714 nNumberOfBytesToLockLow,
715 nNumberOfBytesToLockHigh));
716}
717//******************************************************************************
718//******************************************************************************
719ODINFUNCTION3(DWORD, GetShortPathNameA,
720 LPCTSTR, lpszLongPath,
721 LPTSTR, lpszShortPath,
722 DWORD, cchBuffer)
723{
724 int length;
725
726 dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it\n", lpszLongPath));
727 length = strlen(lpszLongPath) + 1;
728 if(length > cchBuffer) {
729 *lpszShortPath = 0;
730 return(length);
731 }
732 memcpy(lpszShortPath, lpszLongPath, length);
733 return(length-1);
734}
735//******************************************************************************
736//******************************************************************************
737ODINFUNCTION3(DWORD, GetShortPathNameW,
738 LPCWSTR, lpszLongPath,
739 LPWSTR, lpszShortPath,
740 DWORD, cchBuffer)
741{
742 int length;
743
744 dprintf(("KERNEL32: GetShortPathNameW; just copying it\n"));
745 length = UniStrlen((UniChar*)lpszLongPath) + 1;
746 if(length > cchBuffer) {
747 *lpszShortPath = 0;
748 return(length);
749 }
750 memcpy(lpszShortPath, lpszLongPath, length*sizeof(USHORT));
751 return(length-1);
752}
753//******************************************************************************
754//******************************************************************************
755ODINFUNCTION3(HANDLE, FindFirstChangeNotificationA,
756 LPCSTR, lpPathName,
757 BOOL, bWatchSubtree,
758 DWORD, dwNotifyFilter)
759{
760 dprintf(("KERNEL32: FindFirstChangeNotificationA, Not implemented\n"));
761 return(0);
762}
763//******************************************************************************
764//******************************************************************************
765ODINFUNCTION1(BOOL, FindNextChangeNotification,
766 HANDLE, hChange)
767{
768 dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
769 hChange));
770
771 return(0);
772}
773//******************************************************************************
774//******************************************************************************
775ODINPROCEDURE0(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
795ODINFUNCTION2(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
823ODINFUNCTION2(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
857ODINFUNCTION3(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
902ODINFUNCTION3(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
Note: See TracBrowser for help on using the repository browser.