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

Last change on this file since 3697 was 3697, checked in by phaller, 25 years ago

Removed obsolete debug output

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