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

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

file map flush & FindFirstA fixes

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