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

Last change on this file since 3269 was 3269, checked in by cbratschi, 25 years ago

FindFirst* changes

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