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

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

GetFileTime bugfix + FindResource(Ex)A/W changes + setup thread security objects during creation

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