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

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

Rewrote file io apis

File size: 36.1 KB
Line 
1/* $Id: Fileio.cpp,v 1.34 2000-06-01 11:28:45 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 *, 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 dprintf(("KERNEL32: SetFilePointer(%08xh,%08xh,%08xh,%08xh)\n",
474 hFile,
475 lDistanceToMove,
476 lpDistanceToMoveHigh,
477 dwMoveMethod));
478
479 return(HMSetFilePointer(hFile,
480 lDistanceToMove,
481 lpDistanceToMoveHigh,
482 dwMoveMethod));
483}
484//******************************************************************************
485//******************************************************************************
486ODINFUNCTION1(DWORD, GetFileAttributesA,
487 LPCSTR, lpszFileName)
488{
489 DWORD rc, error;
490
491 if((NULL!=lpszFileName) && strlen(lpszFileName)==2 && lpszFileName[1] == ':')
492 {
493 char szDrive[4];
494 szDrive[0] = lpszFileName[0];
495 szDrive[1] = lpszFileName[1];
496 szDrive[2] = '\\';
497 szDrive[3] = 0x00;
498 rc = O32_GetFileAttributes((LPSTR)szDrive);
499 }
500 else {
501 rc = O32_GetFileAttributes((LPSTR)lpszFileName);
502 if(rc == -1 && lpszFileName[strlen(lpszFileName)-1] != '\\') {
503 char *filename = (char *)alloca(strlen(lpszFileName)+1);
504 strcpy(filename, lpszFileName);
505 strcat(filename, "\\");
506 rc = O32_GetFileAttributes((LPSTR)filename);
507 }
508 }
509 //SvL: Open32 returns FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_NORMAL for
510 // directories whereas NT 4 (SP6) only returns FILE_ATTRIBUTE_DIRECTORY
511 if(rc != -1 && (rc & FILE_ATTRIBUTE_DIRECTORY)) {
512 rc = FILE_ATTRIBUTE_DIRECTORY;
513 }
514
515#if 0 // need more tests, maybe there is also a better way to hide simulated b:
516 if(rc == -1 && lpszFileName != NULL && !strnicmp(lpszFileName, "B:", 2))
517 {
518 error = GetLastError();
519 if(error = ERROR_DISK_CHANGE)
520 SetLastError(ERROR_NOT_READY);
521 else
522 SetLastError(error);
523 }
524#endif
525 dprintf(("KERNEL32: GetFileAttributes of %s returned %d\n", lpszFileName, rc));
526 return(rc);
527}
528//******************************************************************************
529//******************************************************************************
530ODINFUNCTION1(DWORD, GetFileAttributesW,
531 LPCWSTR, arg1)
532{
533 DWORD rc;
534 char *astring;
535
536 dprintf(("KERNEL32: GetFileAttributesW\n"));
537 astring = UnicodeToAsciiString((LPWSTR)arg1);
538 rc = ODIN_GetFileAttributesA(astring);
539 FreeAsciiString(astring);
540 return(rc);
541}
542//******************************************************************************
543//******************************************************************************
544ODINFUNCTION2(BOOL, SetFileAttributesA,
545 LPCSTR, arg1,
546 DWORD, arg2)
547{
548 dprintf(("KERNEL32: SetFileAttributes of %s\n", arg1));
549 return O32_SetFileAttributes(arg1, arg2);
550}
551//******************************************************************************
552//******************************************************************************
553ODINFUNCTION2(BOOL, SetFileAttributesW,
554 LPCWSTR, lpFileName,
555 DWORD, dwFileAttributes)
556{
557 char *asciifile;
558 BOOL rc;
559
560 dprintf(("KERNEL32: SetFileAttributesW\n"));
561 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
562 rc = O32_SetFileAttributes(asciifile, dwFileAttributes);
563 FreeAsciiString(asciifile);
564 return(rc);
565}
566//******************************************************************************
567//******************************************************************************
568ODINFUNCTION4(DWORD, GetFullPathNameA,
569 LPCSTR, arg1,
570 DWORD, arg2,
571 LPSTR, arg3,
572 LPSTR *, arg4)
573{
574 char *ptr;
575 dprintf(("KERNEL32: GetFullPathName %s\n", arg1));
576 while((ptr = strchr(arg1, '/')) != NULL)
577 *ptr = '\\';
578 return O32_GetFullPathName(arg1, arg2, arg3, arg4);
579}
580//******************************************************************************
581//******************************************************************************
582ODINFUNCTION4(DWORD, GetFullPathNameW,
583 LPCWSTR, lpFileName,
584 DWORD, nBufferLength,
585 LPWSTR, lpBuffer,
586 LPWSTR *, lpFilePart)
587{
588 char *astring, *asciibuffer, *asciipart;
589 DWORD rc;
590
591 asciibuffer = (char *)malloc(nBufferLength+1);
592 astring = UnicodeToAsciiString((LPWSTR)lpFileName);
593
594 rc = ODIN_GetFullPathNameA(astring,
595 nBufferLength,
596 asciibuffer,
597 &asciipart);
598
599 dprintf(("KERNEL32: GetFullPathNameW %s returns %s\n",
600 astring,
601 asciibuffer));
602
603 if(rc)
604 AsciiToUnicode(asciibuffer,
605 lpBuffer);
606
607 if(lpFilePart)
608 *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
609
610 FreeAsciiString(astring);
611 free(asciibuffer);
612 return(rc);
613}
614//******************************************************************************
615//******************************************************************************
616ODINFUNCTION5(BOOL, LockFile,
617 HANDLE, arg1,
618 DWORD, arg2,
619 DWORD, arg3,
620 DWORD, arg4,
621 DWORD, arg5)
622{
623 dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n",
624 arg1,
625 arg2,
626 arg3,
627 arg4,
628 arg5));
629
630 return HMLockFile(arg1,
631 arg2,
632 arg3,
633 arg4,
634 arg5);
635}
636
637
638/*****************************************************************************
639 * Name : BOOL LockFileEx
640 * Purpose : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
641 * Parameters: HANDLE hFile handle of file to lock
642 * DWORD dwFlags functional behavior modification flags
643 * DWORD dwReserved reserved, must be set to zero
644 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
645 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
646 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
647 * Variables :
648 * Result : TRUE / FALSE
649 * Remark :
650 * Status : UNTESTED STUB
651 *
652 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
653 *****************************************************************************/
654
655ODINFUNCTION6(BOOL, LockFileEx,
656 HANDLE, hFile,
657 DWORD, dwFlags,
658 DWORD, dwReserved,
659 DWORD, nNumberOfBytesToLockLow,
660 DWORD, nNumberOfBytesToLockHigh,
661 LPOVERLAPPED, lpOverlapped)
662{
663 dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
664 hFile,
665 dwFlags,
666 dwReserved,
667 nNumberOfBytesToLockLow,
668 nNumberOfBytesToLockHigh,
669 lpOverlapped));
670
671 return(HMLockFile(hFile,
672 lpOverlapped->Offset,
673 lpOverlapped->OffsetHigh,
674 nNumberOfBytesToLockLow,
675 nNumberOfBytesToLockHigh));
676}
677
678
679
680
681//******************************************************************************
682//******************************************************************************
683ODINFUNCTION2(BOOL, MoveFileA,
684 LPCSTR, arg1,
685 LPCSTR, arg2)
686{
687 dprintf(("KERNEL32: MoveFileA %s %s", arg1, arg2));
688 return O32_MoveFile(arg1, arg2);
689}
690//******************************************************************************
691//******************************************************************************
692ODINFUNCTION3(BOOL, MoveFileExA,
693 LPCSTR, arg1,
694 LPCSTR, arg2,
695 DWORD, fdwFlags)
696{
697 dprintf(("KERNEL32: MoveFileExA %s to %s, not complete!\n", arg1, arg2));
698 return O32_MoveFile(arg1, arg2);
699}
700//******************************************************************************
701//******************************************************************************
702ODINFUNCTION2(BOOL, MoveFileW,
703 LPCWSTR, lpSrc,
704 LPCWSTR, lpDest)
705{
706 char *asciisrc, *asciidest;
707 BOOL rc;
708
709 dprintf(("KERNEL32: MoveFileW\n"));
710 asciisrc = UnicodeToAsciiString((LPWSTR)lpSrc);
711 asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
712 rc = O32_MoveFile(asciisrc, asciidest);
713 FreeAsciiString(asciisrc);
714 FreeAsciiString(asciidest);
715 return(rc);
716}
717//******************************************************************************
718//******************************************************************************
719ODINFUNCTION3(BOOL, MoveFileExW,
720 LPCWSTR, arg1,
721 LPCWSTR, arg2,
722 DWORD, fdwFlags)
723{
724 dprintf(("KERNEL32: MoveFileExW %s to %s, not complete!\n", arg1, arg2));
725 return MoveFileW(arg1, arg2);
726}
727//******************************************************************************
728/*****************************************************************************
729ODINFUNCTION3(*, :,
730 HFILE, WIN32API,
731 OpenFile *, Purpose,
732 :, forwardOpenFile to Open32
733 * Parameters:
734 * Variables :
735 * Result : API returncode
736 * Remark : modified for handle translation support
737 * Status : @@@PH verify if 0 is a valid "invalid handle" :)
738 *
739 * Author : Patrick Haller [Fri, 1998/06/12 02:53]
740 *****************************************************************************/
741
742ODINFUNCTION3(HFILE, OpenFile,
743 LPCSTR, lpszFile,
744 OFSTRUCT *, lpOpenBuff,
745 UINT, fuMode)
746{
747 HFILE hFile;
748
749 dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
750 lpszFile,
751 lpOpenBuff,
752 fuMode));
753
754 hFile = HMOpenFile(lpszFile, /* call open32 */
755 lpOpenBuff,
756 fuMode);
757
758 return (hFile);
759}
760//******************************************************************************
761//******************************************************************************
762ODINFUNCTION5(BOOL, UnlockFile,
763 HANDLE, arg1,
764 DWORD, arg2,
765 DWORD, arg3,
766 DWORD, arg4,
767 DWORD, arg5)
768{
769 dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
770 arg1,
771 arg2,
772 arg3,
773 arg4,
774 arg5));
775
776 return HMUnlockFile(arg1,
777 arg2,
778 arg3,
779 arg4,
780 arg5);
781}
782
783
784/*****************************************************************************
785 * Name : BOOL UnlockFileEx
786 * Purpose : The UnlockFileEx function unlocks a previously locked byte range in an open file.
787 * Parameters: HANDLE hFile handle of file to lock
788 * DWORD dwReserved reserved, must be set to zero
789 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
790 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
791 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
792 * Variables :
793 * Result : TRUE / FALSE
794 * Remark :
795 * Status : UNTESTED STUB
796 *
797 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
798 *****************************************************************************/
799
800ODINFUNCTION5(BOOL, UnlockFileEx,
801 HANDLE, hFile,
802 DWORD, dwReserved,
803 DWORD, nNumberOfBytesToLockLow,
804 DWORD, nNumberOfBytesToLockHigh,
805 LPOVERLAPPED, lpOverlapped)
806{
807 dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
808 hFile,
809 dwReserved,
810 nNumberOfBytesToLockLow,
811 nNumberOfBytesToLockHigh,
812 lpOverlapped));
813
814 return(HMUnlockFileEx(hFile, dwReserved,
815 nNumberOfBytesToLockLow,
816 nNumberOfBytesToLockHigh,
817 lpOverlapped));
818}
819//******************************************************************************
820//******************************************************************************
821ODINFUNCTION3(DWORD, GetShortPathNameA,
822 LPCTSTR, lpszLongPath,
823 LPTSTR, lpszShortPath,
824 DWORD, cchBuffer)
825{
826 int length;
827
828 dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it\n", lpszLongPath));
829 length = strlen(lpszLongPath) + 1;
830 if(length > cchBuffer) {
831 *lpszShortPath = 0;
832 return(length);
833 }
834 memcpy(lpszShortPath, lpszLongPath, length);
835 return(length-1);
836}
837//******************************************************************************
838//******************************************************************************
839ODINFUNCTION3(DWORD, GetShortPathNameW,
840 LPCWSTR, lpszLongPath,
841 LPWSTR, lpszShortPath,
842 DWORD, cchBuffer)
843{
844 int length;
845
846 dprintf(("KERNEL32: GetShortPathNameW; just copying it\n"));
847 length = UniStrlen((UniChar*)lpszLongPath) + 1;
848 if(length > cchBuffer) {
849 *lpszShortPath = 0;
850 return(length);
851 }
852 memcpy(lpszShortPath, lpszLongPath, length*sizeof(USHORT));
853 return(length-1);
854}
855ODINPROCEDURE0(SetFileApisToANSI)
856{
857 dprintf(("SetFileApisToANSI() stub\n"));
858}
859
860/*****************************************************************************
861 * Name : DWORD GetCompressedFileSizeA
862 * Purpose : The GetCompressedFileSizeA function obtains the compressed
863 * size, in bytes, of a specified file.
864 * Parameters: LPCTSTR lpFileName, // pointer to name of file
865 * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
866 * high-order doubleword of file size
867 * Variables :
868 * Result : size of compressed file
869 * Remark :
870 * Status : UNTESTED
871 *
872 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
873 *****************************************************************************/
874
875ODINFUNCTION2(DWORD, GetCompressedFileSizeA,
876 LPCTSTR, lpFileName,
877 LPDWORD, lpFileSizeHigh)
878{
879 dprintf(("KERNEL32: GetCompressedFileSizeA (%s, %08xh) not implemented.\n",
880 lpFileName,
881 lpFileSizeHigh));
882
883 /* PH: simply return the standard filesize */
884 return 0;
885}
886
887
888/*****************************************************************************
889 * Name : DWORD GetCompressedFileSizeW
890 * Purpose : The GetCompressedFileSizeE function obtains the compressed
891 * size, in bytes, of a specified file.
892 * Parameters: LPCWSTR lpFileName, // pointer to name of file
893 * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
894 * high-order doubleword of file size
895 * Variables :
896 * Result : size of compressed file
897 * Remark :
898 * Status : UNTESTED
899 *
900 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
901 *****************************************************************************/
902
903ODINFUNCTION2(DWORD, GetCompressedFileSizeW,
904 LPCWSTR, lpFileName,
905 LPDWORD, lpFileSizeHigh)
906{
907 LPCTSTR lpAsciiFileName; /* converted filename */
908 DWORD rc; /* function result */
909
910 dprintf(("KERNEL32: GetCompressedFileSizeW (%s, %08xh)\n",
911 lpFileName,
912 lpFileSizeHigh));
913
914 lpAsciiFileName = UnicodeToAsciiString( (LPWSTR) lpFileName);
915
916 rc = GetCompressedFileSizeA(lpAsciiFileName,
917 lpFileSizeHigh);
918
919 FreeAsciiString( (char *) lpAsciiFileName);
920
921 return (rc); /* return result */
922}
923
924
925/*****************************************************************************
926 * Name : BOOL GetFileAttributesExA
927 * Purpose :
928 * Parameters:
929 * Variables :
930 * Result :
931 * Remark : KERNEL32.874
932 * Status : UNTESTED
933 *
934 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
935 *****************************************************************************/
936
937ODINFUNCTION3(BOOL, GetFileAttributesExA,
938 LPCSTR, lpFileName,
939 GET_FILEEX_INFO_LEVELS, fInfoLevelId,
940 LPVOID, lpFileInformation)
941{
942 BOOL rc;
943
944 dprintf(("KERNEL32: GetFileAttributesExA(%s,%08xh,%08xh) mostly implemented.\n",
945 lpFileName,
946 fInfoLevelId,
947 lpFileInformation));
948
949 if (lpFileName == NULL) return FALSE;
950 if (lpFileInformation == NULL) return FALSE;
951
952 if (fInfoLevelId == GetFileExInfoStandard)
953 {
954 LPWIN32_FILE_ATTRIBUTE_DATA lpFad = (LPWIN32_FILE_ATTRIBUTE_DATA) lpFileInformation;
955
956 rc = OSLibDosGetFileAttributesEx((LPSTR)lpFileName,
957 fInfoLevelId,
958 lpFileInformation);
959 return (rc);
960 }
961 else
962 {
963 dprintf(("KERNEL32: GetFileAttributesExA - invalid info level %d!\n",
964 fInfoLevelId));
965 return FALSE;
966 }
967}
968
969
970/*****************************************************************************
971 * Name : BOOL GetFileAttributesExW
972 * Purpose :
973 * Parameters:
974 * Variables :
975 * Result :
976 * Remark : KERNEL32.875
977 * Status : UNTESTED
978 *
979 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
980 *****************************************************************************/
981
982ODINFUNCTION3(BOOL, GetFileAttributesExW,
983 LPCWSTR, lpFileName,
984 GET_FILEEX_INFO_LEVELS, fInfoLevelId,
985 LPVOID, lpFileInformation)
986{
987 LPSTR nameA = HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName );
988 BOOL res = GetFileAttributesExA( nameA, fInfoLevelId, lpFileInformation);
989 HeapFree( GetProcessHeap(), 0, nameA );
990 return res;
991}
992
993//******************************************************************************
994//******************************************************************************
995ODINFUNCTION3(HANDLE, FindFirstChangeNotificationA,
996 LPCSTR, lpPathName,
997 BOOL, bWatchSubtree,
998 DWORD, dwNotifyFilter)
999{
1000 dprintf(("KERNEL32: FindFirstChangeNotificationA, Not implemented (faked)\n"));
1001 return -1;
1002}
1003//******************************************************************************
1004//******************************************************************************
1005ODINFUNCTION1(BOOL, FindNextChangeNotification,
1006 HANDLE, hChange)
1007{
1008 dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
1009 hChange));
1010
1011 return FALSE;
1012}
1013//******************************************************************************
1014//******************************************************************************
1015ODINFUNCTION1(BOOL, FindCloseChangeNotification, HANDLE, hChange)
1016{
1017 dprintf(("KERNEL32: OS2FindNextChangeNotification, Not implemented\n"));
1018
1019 return(TRUE);
1020}
1021/*****************************************************************************
1022 * Name : HANDLE WIN32API FindFirstChangeNotificationW
1023 * Purpose : The FindFirstChangeNotification function creates a change
1024 * notification handle and sets up initial change notification
1025 * filter conditions. A wait on a notification handle succeeds when
1026 * a change matching the filter conditions occurs in the specified
1027 * directory or subtree.
1028 * Parameters: LPCWSTR lpPathName pointer to name of directory to watch
1029 * BOOL bWatchSubtree flag for monitoring directory or
1030 * directory tree
1031 * DWORD dwNotifyFilter filter conditions to watch for
1032 * Variables :
1033 * Result : If the function succeeds, the return value is a handle to a find
1034 * change notification object.
1035 * If the function fails, the return value is INVALID_HANDLE_VALUE
1036 * Remark :
1037 * Status : UNTESTED STUB
1038 *
1039 * Author : Markus Montkowski [Tha, 1998/05/21 20:57]
1040 *****************************************************************************/
1041ODINFUNCTION3(HANDLE, FindFirstChangeNotificationW, LPCWSTR, lpPathName,
1042 BOOL, bWatchSubtree,
1043 DWORD, dwNotifyFilter)
1044{
1045 LPSTR lpAsciiPath;
1046 HANDLE hChange;
1047
1048 lpAsciiPath = UnicodeToAsciiString( (LPWSTR) lpPathName);
1049 hChange = FindFirstChangeNotificationA(lpAsciiPath, bWatchSubtree,
1050 dwNotifyFilter );
1051 if (lpAsciiPath) FreeAsciiString(lpAsciiPath);
1052 return hChange;
1053}
1054//******************************************************************************
1055//******************************************************************************
Note: See TracBrowser for help on using the repository browser.