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

Last change on this file since 3375 was 3375, checked in by sandervl, 25 years ago

GetFileAttributes, pe loader & command line fixes

File size: 30.6 KB
Line 
1/* $Id: Fileio.cpp,v 1.28 2000-04-14 22:35:25 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 "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 {
408 rc = O32_GetFileAttributes((LPSTR)lpszFileName);
409 if(rc == -1 && lpszFileName[strlen(lpszFileName)-1] != '\\') {
410 char *filename = (char *)alloca(strlen(lpszFileName)+1);
411 strcpy(filename, lpszFileName);
412 strcat(filename, "\\");
413 rc = O32_GetFileAttributes((LPSTR)filename);
414 }
415 }
416
417#if 0 // need more tests, maybe there is also a better way to hide simulated b:
418 if(rc == -1 && lpszFileName != NULL && !strnicmp(lpszFileName, "B:", 2))
419 {
420 error = GetLastError();
421 if(error = ERROR_DISK_CHANGE)
422 SetLastError(ERROR_NOT_READY);
423 else
424 SetLastError(error);
425 }
426#endif
427 dprintf(("KERNEL32: GetFileAttributes of %s returned %d\n", lpszFileName, rc));
428 return(rc);
429}
430//******************************************************************************
431//******************************************************************************
432ODINFUNCTION1(DWORD, GetFileAttributesW,
433 LPCWSTR, arg1)
434{
435 DWORD rc;
436 char *astring;
437
438 dprintf(("KERNEL32: GetFileAttributesW\n"));
439 astring = UnicodeToAsciiString((LPWSTR)arg1);
440 rc = ODIN_GetFileAttributesA(astring);
441 FreeAsciiString(astring);
442 return(rc);
443}
444//******************************************************************************
445//******************************************************************************
446ODINFUNCTION2(BOOL, SetFileAttributesA,
447 LPCSTR, arg1,
448 DWORD, arg2)
449{
450 dprintf(("KERNEL32: SetFileAttributes of %s\n", arg1));
451 return O32_SetFileAttributes(arg1, arg2);
452}
453//******************************************************************************
454//******************************************************************************
455ODINFUNCTION2(BOOL, SetFileAttributesW,
456 LPCWSTR, lpFileName,
457 DWORD, dwFileAttributes)
458{
459 char *asciifile;
460 BOOL rc;
461
462 dprintf(("KERNEL32: SetFileAttributesW\n"));
463 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
464 rc = O32_SetFileAttributes(asciifile, dwFileAttributes);
465 FreeAsciiString(asciifile);
466 return(rc);
467}
468//******************************************************************************
469//******************************************************************************
470ODINFUNCTION4(DWORD, GetFullPathNameA,
471 LPCSTR, arg1,
472 DWORD, arg2,
473 LPSTR, arg3,
474 LPSTR *, arg4)
475{
476 char *ptr;
477 dprintf(("KERNEL32: GetFullPathName %s\n", arg1));
478 while((ptr = strchr(arg1, '/')) != NULL)
479 *ptr = '\\';
480 return O32_GetFullPathName(arg1, arg2, arg3, arg4);
481}
482//******************************************************************************
483//******************************************************************************
484ODINFUNCTION4(DWORD, GetFullPathNameW,
485 LPCWSTR, lpFileName,
486 DWORD, nBufferLength,
487 LPWSTR, lpBuffer,
488 LPWSTR *, lpFilePart)
489{
490 char *astring, *asciibuffer, *asciipart;
491 DWORD rc;
492
493 asciibuffer = (char *)malloc(nBufferLength+1);
494 astring = UnicodeToAsciiString((LPWSTR)lpFileName);
495
496 rc = ODIN_GetFullPathNameA(astring,
497 nBufferLength,
498 asciibuffer,
499 &asciipart);
500
501 dprintf(("KERNEL32: GetFullPathNameW %s returns %s\n",
502 astring,
503 asciibuffer));
504
505 if(rc)
506 AsciiToUnicode(asciibuffer,
507 lpBuffer);
508
509 if(lpFilePart)
510 *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
511
512 FreeAsciiString(astring);
513 free(asciibuffer);
514 return(rc);
515}
516//******************************************************************************
517//******************************************************************************
518ODINFUNCTION5(BOOL, LockFile,
519 HANDLE, arg1,
520 DWORD, arg2,
521 DWORD, arg3,
522 DWORD, arg4,
523 DWORD, arg5)
524{
525 dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n",
526 arg1,
527 arg2,
528 arg3,
529 arg4,
530 arg5));
531
532 return HMLockFile(arg1,
533 arg2,
534 arg3,
535 arg4,
536 arg5);
537}
538
539
540/*****************************************************************************
541 * Name : BOOL LockFileEx
542 * Purpose : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
543 * Parameters: HANDLE hFile handle of file to lock
544 * DWORD dwFlags functional behavior modification flags
545 * DWORD dwReserved reserved, must be set to zero
546 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
547 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
548 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
549 * Variables :
550 * Result : TRUE / FALSE
551 * Remark :
552 * Status : UNTESTED STUB
553 *
554 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
555 *****************************************************************************/
556
557ODINFUNCTION6(BOOL, LockFileEx,
558 HANDLE, hFile,
559 DWORD, dwFlags,
560 DWORD, dwReserved,
561 DWORD, nNumberOfBytesToLockLow,
562 DWORD, nNumberOfBytesToLockHigh,
563 LPOVERLAPPED, lpOverlapped)
564{
565 dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
566 hFile,
567 dwFlags,
568 dwReserved,
569 nNumberOfBytesToLockLow,
570 nNumberOfBytesToLockHigh,
571 lpOverlapped));
572
573 return(HMLockFile(hFile,
574 lpOverlapped->Offset,
575 lpOverlapped->OffsetHigh,
576 nNumberOfBytesToLockLow,
577 nNumberOfBytesToLockHigh));
578}
579
580
581
582
583//******************************************************************************
584//******************************************************************************
585ODINFUNCTION2(BOOL, MoveFileA,
586 LPCSTR, arg1,
587 LPCSTR, arg2)
588{
589 dprintf(("KERNEL32: MoveFileA %s %s", arg1, arg2));
590 return O32_MoveFile(arg1, arg2);
591}
592//******************************************************************************
593//******************************************************************************
594ODINFUNCTION3(BOOL, MoveFileExA,
595 LPCSTR, arg1,
596 LPCSTR, arg2,
597 DWORD, fdwFlags)
598{
599 dprintf(("KERNEL32: MoveFileExA %s to %s, not complete!\n", arg1, arg2));
600 return O32_MoveFile(arg1, arg2);
601}
602//******************************************************************************
603//******************************************************************************
604ODINFUNCTION2(BOOL, MoveFileW,
605 LPCWSTR, lpSrc,
606 LPCWSTR, lpDest)
607{
608 char *asciisrc, *asciidest;
609 BOOL rc;
610
611 dprintf(("KERNEL32: MoveFileW\n"));
612 asciisrc = UnicodeToAsciiString((LPWSTR)lpSrc);
613 asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
614 rc = O32_MoveFile(asciisrc, asciidest);
615 FreeAsciiString(asciisrc);
616 FreeAsciiString(asciidest);
617 return(rc);
618}
619//******************************************************************************
620//******************************************************************************
621ODINFUNCTION3(BOOL, MoveFileExW,
622 LPCWSTR, arg1,
623 LPCWSTR, arg2,
624 DWORD, fdwFlags)
625{
626 dprintf(("KERNEL32: MoveFileExW %s to %s, not complete!\n", arg1, arg2));
627 return MoveFileW(arg1, arg2);
628}
629//******************************************************************************
630/*****************************************************************************
631ODINFUNCTION3(*, :,
632 HFILE, WIN32API,
633 OpenFile *, Purpose,
634 :, forwardOpenFile to Open32
635 * Parameters:
636 * Variables :
637 * Result : API returncode
638 * Remark : modified for handle translation support
639 * Status : @@@PH verify if 0 is a valid "invalid handle" :)
640 *
641 * Author : Patrick Haller [Fri, 1998/06/12 02:53]
642 *****************************************************************************/
643
644ODINFUNCTION3(HFILE, OpenFile,
645 LPCSTR, lpszFile,
646 OFSTRUCT *, lpOpenBuff,
647 UINT, fuMode)
648{
649 HFILE hFile;
650
651 dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
652 lpszFile,
653 lpOpenBuff,
654 fuMode));
655
656 hFile = HMOpenFile(lpszFile, /* call open32 */
657 lpOpenBuff,
658 fuMode);
659
660 return (hFile);
661}
662//******************************************************************************
663//******************************************************************************
664ODINFUNCTION5(BOOL, UnlockFile,
665 HANDLE, arg1,
666 DWORD, arg2,
667 DWORD, arg3,
668 DWORD, arg4,
669 DWORD, arg5)
670{
671 dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
672 arg1,
673 arg2,
674 arg3,
675 arg4,
676 arg5));
677
678 return HMUnlockFile(arg1,
679 arg2,
680 arg3,
681 arg4,
682 arg5);
683}
684
685
686/*****************************************************************************
687 * Name : BOOL UnlockFileEx
688 * Purpose : The UnlockFileEx function unlocks a previously locked byte range in an open file.
689 * Parameters: HANDLE hFile handle of file to lock
690 * DWORD dwReserved reserved, must be set to zero
691 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
692 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
693 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
694 * Variables :
695 * Result : TRUE / FALSE
696 * Remark :
697 * Status : UNTESTED STUB
698 *
699 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
700 *****************************************************************************/
701
702ODINFUNCTION5(BOOL, UnlockFileEx,
703 HANDLE, hFile,
704 DWORD, dwReserved,
705 DWORD, nNumberOfBytesToLockLow,
706 DWORD, nNumberOfBytesToLockHigh,
707 LPOVERLAPPED, lpOverlapped)
708{
709 dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
710 hFile,
711 dwReserved,
712 nNumberOfBytesToLockLow,
713 nNumberOfBytesToLockHigh,
714 lpOverlapped));
715
716 return(HMUnlockFile(hFile,
717 lpOverlapped->Offset,
718 lpOverlapped->OffsetHigh,
719 nNumberOfBytesToLockLow,
720 nNumberOfBytesToLockHigh));
721}
722//******************************************************************************
723//******************************************************************************
724ODINFUNCTION3(DWORD, GetShortPathNameA,
725 LPCTSTR, lpszLongPath,
726 LPTSTR, lpszShortPath,
727 DWORD, cchBuffer)
728{
729 int length;
730
731 dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it\n", lpszLongPath));
732 length = strlen(lpszLongPath) + 1;
733 if(length > cchBuffer) {
734 *lpszShortPath = 0;
735 return(length);
736 }
737 memcpy(lpszShortPath, lpszLongPath, length);
738 return(length-1);
739}
740//******************************************************************************
741//******************************************************************************
742ODINFUNCTION3(DWORD, GetShortPathNameW,
743 LPCWSTR, lpszLongPath,
744 LPWSTR, lpszShortPath,
745 DWORD, cchBuffer)
746{
747 int length;
748
749 dprintf(("KERNEL32: GetShortPathNameW; just copying it\n"));
750 length = UniStrlen((UniChar*)lpszLongPath) + 1;
751 if(length > cchBuffer) {
752 *lpszShortPath = 0;
753 return(length);
754 }
755 memcpy(lpszShortPath, lpszLongPath, length*sizeof(USHORT));
756 return(length-1);
757}
758//******************************************************************************
759//******************************************************************************
760ODINFUNCTION3(HANDLE, FindFirstChangeNotificationA,
761 LPCSTR, lpPathName,
762 BOOL, bWatchSubtree,
763 DWORD, dwNotifyFilter)
764{
765 dprintf(("KERNEL32: FindFirstChangeNotificationA, Not implemented\n"));
766 return(0);
767}
768//******************************************************************************
769//******************************************************************************
770ODINFUNCTION1(BOOL, FindNextChangeNotification,
771 HANDLE, hChange)
772{
773 dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
774 hChange));
775
776 return(0);
777}
778//******************************************************************************
779//******************************************************************************
780ODINPROCEDURE0(SetFileApisToANSI)
781{
782 dprintf(("SetFileApisToANSI() stub\n"));
783}
784
785/*****************************************************************************
786 * Name : DWORD GetCompressedFileSizeA
787 * Purpose : The GetCompressedFileSizeA function obtains the compressed
788 * size, in bytes, of a specified file.
789 * Parameters: LPCTSTR lpFileName, // pointer to name of file
790 * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
791 * high-order doubleword of file size
792 * Variables :
793 * Result : size of compressed file
794 * Remark :
795 * Status : UNTESTED
796 *
797 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
798 *****************************************************************************/
799
800ODINFUNCTION2(DWORD, GetCompressedFileSizeA,
801 LPCTSTR, lpFileName,
802 LPDWORD, lpFileSizeHigh)
803{
804 dprintf(("KERNEL32: GetCompressedFileSizeA (%s, %08xh) not implemented.\n",
805 lpFileName,
806 lpFileSizeHigh));
807
808 /* PH: simply return the standard filesize */
809 return 0;
810}
811
812
813/*****************************************************************************
814 * Name : DWORD GetCompressedFileSizeW
815 * Purpose : The GetCompressedFileSizeE function obtains the compressed
816 * size, in bytes, of a specified file.
817 * Parameters: LPCWSTR lpFileName, // pointer to name of file
818 * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
819 * high-order doubleword of file size
820 * Variables :
821 * Result : size of compressed file
822 * Remark :
823 * Status : UNTESTED
824 *
825 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
826 *****************************************************************************/
827
828ODINFUNCTION2(DWORD, GetCompressedFileSizeW,
829 LPCWSTR, lpFileName,
830 LPDWORD, lpFileSizeHigh)
831{
832 LPCTSTR lpAsciiFileName; /* converted filename */
833 DWORD rc; /* function result */
834
835 dprintf(("KERNEL32: GetCompressedFileSizeW (%s, %08xh)\n",
836 lpFileName,
837 lpFileSizeHigh));
838
839 lpAsciiFileName = UnicodeToAsciiString( (LPWSTR) lpFileName);
840
841 rc = GetCompressedFileSizeA(lpAsciiFileName,
842 lpFileSizeHigh);
843
844 FreeAsciiString( (char *) lpAsciiFileName);
845
846 return (rc); /* return result */
847}
848
849
850/*****************************************************************************
851 * Name : BOOL GetFileAttributesExA
852 * Purpose :
853 * Parameters:
854 * Variables :
855 * Result :
856 * Remark : KERNEL32.874
857 * Status : UNTESTED
858 *
859 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
860 *****************************************************************************/
861
862ODINFUNCTION3(BOOL, GetFileAttributesExA,
863 LPCSTR, lpFileName,
864 GET_FILEEX_INFO_LEVELS, fInfoLevelId,
865 LPVOID, lpFileInformation)
866{
867 BOOL rc;
868
869 dprintf(("KERNEL32: GetFileAttributesExA(%s,%08xh,%08xh) mostly implemented.\n",
870 lpFileName,
871 fInfoLevelId,
872 lpFileInformation));
873
874 if (lpFileName == NULL) return FALSE;
875 if (lpFileInformation == NULL) return FALSE;
876
877 if (fInfoLevelId == GetFileExInfoStandard)
878 {
879 LPWIN32_FILE_ATTRIBUTE_DATA lpFad = (LPWIN32_FILE_ATTRIBUTE_DATA) lpFileInformation;
880
881 rc = OSLibDosGetFileAttributesEx((LPSTR)lpFileName,
882 fInfoLevelId,
883 lpFileInformation);
884 return (rc);
885 }
886 else
887 {
888 dprintf(("KERNEL32: GetFileAttributesExA - invalid info level %d!\n",
889 fInfoLevelId));
890 return FALSE;
891 }
892}
893
894
895/*****************************************************************************
896 * Name : BOOL GetFileAttributesExW
897 * Purpose :
898 * Parameters:
899 * Variables :
900 * Result :
901 * Remark : KERNEL32.875
902 * Status : UNTESTED
903 *
904 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
905 *****************************************************************************/
906
907ODINFUNCTION3(BOOL, GetFileAttributesExW,
908 LPCWSTR, lpFileName,
909 GET_FILEEX_INFO_LEVELS, fInfoLevelId,
910 LPVOID, lpFileInformation)
911{
912 LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
913 BOOL res = GetFileAttributesExA( nameA, fInfoLevelId, lpFileInformation);
914 HeapFree( GetProcessHeap(), 0, nameA );
915 return res;
916}
917
918
Note: See TracBrowser for help on using the repository browser.