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

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

added exception stack dump code; GetLocaleInfoA fixes

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