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

Last change on this file since 75 was 75, checked in by phaller, 26 years ago

Fix: experimental HandleManager support to get Winhlp32 running

File size: 31.6 KB
Line 
1/*
2 *
3 * Project Odin Software License can be found in LICENSE.TXT
4 *
5 */
6/*
7 * Win32 File IO API functions for OS/2
8 *
9 * Copyright 1998 Sander van Leeuwen
10 * Copyright 1998 Patrick Haller
11 *
12 */
13#include <os2win.h>
14#include <stdlib.h>
15#include <string.h>
16#include "unicode.h"
17#include "handlemanager.h"
18#include "devio.h"
19
20//******************************************************************************
21//******************************************************************************
22HFILE WIN32API CreateFileA(LPCSTR lpszName,
23 DWORD fdwAccess,
24 DWORD fdwShareMode,
25 LPSECURITY_ATTRIBUTES lpsa,
26 DWORD fdwCreate,
27 DWORD fdwAttrsAndFlags,
28 HANDLE hTemplateFile)
29{
30 HANDLE rc;
31 HANDLE hFile;
32
33 if(lpszName == NULL)
34 return(NULL);
35
36 dprintf(("KERNEL32: CreateFile %s\n", lpszName));
37
38 if(strncmp(lpszName,
39 "\\\\.\\",
40 4) == 0)
41 {
42 return(OS2CreateFile((char *)&lpszName[4],
43 fdwAccess,
44 fdwShareMode));
45 }
46
47 dprintf(("KERNEL32: CreateFileA(%s,%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
48 lpszName,
49 fdwAccess,
50 fdwShareMode,
51 lpsa,
52 fdwCreate,
53 fdwAttrsAndFlags,
54 hTemplateFile));
55
56 rc = O32_CreateFile(lpszName,
57 fdwAccess,
58 fdwShareMode,
59 lpsa,
60 fdwCreate,
61 fdwAttrsAndFlags,
62 hTemplateFile);
63
64 /* @@@PH 1998/02/12 Handle Manager support */
65 if (rc == -1)
66 rc = HMCreateFile(lpszName,
67 fdwAccess,
68 fdwShareMode,
69 lpsa,
70 fdwCreate,
71 fdwAttrsAndFlags,
72 hTemplateFile);
73
74 /* @@@PH experimental Handlemanager support */
75 if (HMHandleAllocate(&hFile,
76 rc) == NO_ERROR)
77 rc = hFile;
78
79 dprintf(("KERNEL32: CreateFile returned %08xh\n",
80 rc));
81
82 return(rc);
83}
84//******************************************************************************
85//******************************************************************************
86HFILE WIN32API CreateFileW(LPCWSTR arg1,
87 DWORD arg2,
88 DWORD arg3,
89 PSECURITY_ATTRIBUTES arg4,
90 DWORD arg5,
91 DWORD arg6,
92 HANDLE arg7)
93{
94 HANDLE rc;
95 char *astring;
96
97 dprintf(("KERNEL32: CreateFileW"));
98 astring = UnicodeToAsciiString((LPWSTR)arg1);
99 rc = CreateFileA(astring, arg2, arg3, arg4, arg5, arg6, arg7);
100 FreeAsciiString(astring);
101 return(rc);
102}
103//******************************************************************************
104//******************************************************************************
105HANDLE WIN32API FindFirstFileA(LPCSTR arg1, WIN32_FIND_DATAA * arg2)
106{
107 dprintf(("KERNEL32: FindFirstFile %s\n", arg1));
108
109 return O32_FindFirstFile(arg1, arg2);
110}
111//******************************************************************************
112//******************************************************************************
113HANDLE WIN32API FindFirstFileW(LPCWSTR arg1, WIN32_FIND_DATAW * arg2)
114{
115 HANDLE rc;
116 char *astring;
117
118 dprintf(("KERNEL32: FindFirstFileW: not implemented!!"));
119
120 astring = UnicodeToAsciiString((LPWSTR)arg1);
121// rc = O32_FindFirstFile(astring, arg2);
122 rc = 0;
123 FreeAsciiString(astring);
124 return(rc);
125}
126//******************************************************************************
127//******************************************************************************
128BOOL WIN32API FindNextFileA(HANDLE arg1, WIN32_FIND_DATAA * arg2)
129{
130 dprintf(("KERNEL32: FindNextFile"));
131 return O32_FindNextFile(arg1, arg2);
132}
133//******************************************************************************
134//TODO: convert string in WIN32_FIND_DATAW * structure
135//******************************************************************************
136BOOL WIN32API FindNextFileW(HANDLE arg1, WIN32_FIND_DATAW * arg2)
137{
138 dprintf(("KERNEL32: FindNextFileW Not properly implemented!\n"));
139// return O32_FindNextFile(arg1, arg2);
140 return 0;
141}
142//******************************************************************************
143//******************************************************************************
144BOOL WIN32API FindClose(HANDLE arg1)
145{
146 dprintf(("KERNEL32: FindClose\n"));
147 return O32_FindClose(arg1);
148}
149//******************************************************************************
150//******************************************************************************
151DWORD WIN32API GetFileType(HANDLE file)
152{
153 DWORD rc;
154 HFILE hFile;
155
156 /* @@@PH 1998/02/12 Handle Manager support */
157 if (IS_HM_HANDLE(file))
158 return (HMGetFileType(file));
159
160 /* @@@PH experimental Handlemanager support */
161 if (HMHandleTranslateToOS2(file,
162 &hFile) == NO_ERROR)
163 file = hFile;
164
165 dprintf(("KERNEL32: GetFileType %08xh\n",
166 file));
167
168 rc = O32_GetFileType(file);
169 if(rc == 0)
170 {
171 //bugfix
172 rc = 1;
173 }
174
175 dprintf(("KERNEL32: GetFileType returned %08xh\n",
176 rc));
177
178 return(rc);
179}
180//******************************************************************************
181//******************************************************************************
182DWORD WIN32API GetFileInformationByHandle(HANDLE arg1,
183 BY_HANDLE_FILE_INFORMATION *arg2)
184{
185 DWORD rc;
186 HFILE hFile;
187
188 /* @@@PH experimental Handlemanager support */
189 if (HMHandleTranslateToOS2(arg1,
190 &hFile) == NO_ERROR)
191 arg1 = hFile;
192
193
194 rc = O32_GetFileInformationByHandle(arg1,
195 arg2);
196
197 dprintf(("KERNEL32: GetFileInformationByHandle (%08xh) returned %08xh\n",
198 arg1,
199 rc));
200
201 /* @@@PH irrelevant
202 if(rc == 0)
203 {
204 //might be converted _lopen handle, so go get it
205 // arg1 = ConvertHandle(arg1);
206 rc = O32_GetFileInformationByHandle(arg1, arg2);
207 dprintf(("KERNEL32: GetFileInformationByHandle (%X) returned %d\n", arg1, rc));
208 }
209 */
210
211 return(rc);
212}
213//******************************************************************************
214//******************************************************************************
215BOOL WIN32API SetEndOfFile( HANDLE arg1)
216{
217 HFILE hFile;
218
219 /* @@@PH experimental Handlemanager support */
220 if (HMHandleTranslateToOS2(arg1,
221 &hFile) == NO_ERROR)
222 arg1 = hFile;
223
224 dprintf(("KERNEL32: SetEndOfFile(%08xh)\n",
225 arg1));
226
227 return O32_SetEndOfFile(arg1);
228}
229//******************************************************************************
230//******************************************************************************
231BOOL WIN32API SetFileTime(HANDLE arg1,
232 const FILETIME *arg2,
233 const FILETIME *arg3,
234 const FILETIME *arg4)
235{
236 HFILE hFile;
237
238 /* @@@PH experimental Handlemanager support */
239 if (HMHandleTranslateToOS2(arg1,
240 &hFile) == NO_ERROR)
241 arg1 = hFile;
242
243 dprintf(("KERNEL32: SetFileTime(%08xh,%08xh,%08xh,%08xh)\n",
244 arg1,
245 arg2,
246 arg3,
247 arg4));
248
249 return O32_SetFileTime(arg1,
250 arg2,
251 arg3,
252 arg4);
253}
254//******************************************************************************
255//******************************************************************************
256INT WIN32API CompareFileTime( FILETIME * arg1, FILETIME * arg2)
257{
258 dprintf(("KERNEL32: CompareFileTime\n"));
259 return O32_CompareFileTime(arg1, arg2);
260}
261//******************************************************************************
262//******************************************************************************
263BOOL WIN32API CopyFileA(LPCSTR arg1, LPCSTR arg2, BOOL arg3)
264{
265 dprintf(("KERNEL32: CopyFile %s %s\n", arg1, arg2));
266 return O32_CopyFile(arg1, arg2, arg3);
267}
268//******************************************************************************
269//SvL: 24-6-'97 - Added
270//******************************************************************************
271BOOL WIN32API CopyFileW(LPCWSTR arg1, LPCWSTR arg2, BOOL arg3)
272{
273 BOOL rc;
274 char *astring1, *astring2;
275
276 astring1 = UnicodeToAsciiString((LPWSTR)arg1);
277 astring2 = UnicodeToAsciiString((LPWSTR)arg2);
278 dprintf(("KERNEL32: CopyFileW\n"));
279 rc = O32_CopyFile(astring1, astring2, arg3);
280 FreeAsciiString(astring2);
281 FreeAsciiString(astring1);
282 return(rc);
283}
284//******************************************************************************
285//******************************************************************************
286DWORD WIN32API GetFileSize( HANDLE arg1, PDWORD arg2)
287{
288 HFILE hFile;
289
290 /* @@@PH experimental Handlemanager support */
291 if (HMHandleTranslateToOS2(arg1,
292 &hFile) == NO_ERROR)
293 arg1 = hFile;
294
295 dprintf(("KERNEL32: GetFileSize (%08xh, %08xh)\n",
296 arg1,
297 arg2));
298
299 return O32_GetFileSize(arg1,
300 arg2);
301}
302//******************************************************************************
303//******************************************************************************
304BOOL WIN32API DeleteFileA(LPCSTR arg1)
305{
306 dprintf(("KERNEL32: DeleteFile %s\n", arg1));
307 return O32_DeleteFile(arg1);
308}
309//******************************************************************************
310//******************************************************************************
311BOOL WIN32API DeleteFileW(LPCWSTR arg1)
312{
313 BOOL rc;
314 char *astring;
315
316 dprintf(("KERNEL32: DeleteFileW\n"));
317 astring = UnicodeToAsciiString((LPWSTR)arg1);
318 rc = O32_DeleteFile(astring);
319 FreeAsciiString(astring);
320 return(rc);
321}
322//******************************************************************************
323//******************************************************************************
324UINT WIN32API GetTempFileNameA(LPCSTR arg1, LPCSTR arg2, UINT arg3, LPSTR arg4)
325{
326 dprintf(("KERNEL32: GetTempFileName"));
327 return O32_GetTempFileName(arg1, arg2, arg3, arg4);
328}
329//******************************************************************************
330//******************************************************************************
331UINT WIN32API GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString,
332 UINT uUnique, LPWSTR lpTempFileName)
333{
334 char *asciipath, *asciiprefix;
335 char *asciitemp = (char *)malloc(MAX_PATH+1);
336 UINT rc;
337
338 dprintf(("KERNEL32: GetTempFileNameW"));
339 asciipath = UnicodeToAsciiString((LPWSTR)lpPathName);
340 asciiprefix = UnicodeToAsciiString((LPWSTR)lpPrefixString);
341 rc = O32_GetTempFileName(asciipath, asciiprefix, uUnique, asciitemp);
342 if(rc) AsciiToUnicode(asciitemp, lpTempFileName);
343 FreeAsciiString(asciiprefix);
344 FreeAsciiString(asciipath);
345 free(asciitemp);
346 return(rc);
347}
348//******************************************************************************
349//******************************************************************************
350UINT WIN32API GetTempPathA(UINT arg1, LPSTR arg2)
351{
352 dprintf(("KERNEL32: GetTempPath\n"));
353 return O32_GetTempPath(arg1, arg2);
354}
355//******************************************************************************
356//******************************************************************************
357UINT WIN32API GetTempPathW(UINT nBufferLength, LPWSTR lpBuffer)
358{
359 char *asciibuffer = (char *)malloc(nBufferLength+1);
360 DWORD rc;
361
362 dprintf(("KERNEL32: GetTempPathW\n"));
363 rc = O32_GetTempPath(nBufferLength, asciibuffer);
364 if(rc) AsciiToUnicode(asciibuffer, lpBuffer);
365 free(asciibuffer);
366 return(rc);
367}
368//******************************************************************************
369//******************************************************************************
370BOOL WIN32API ReadFile(HANDLE arg1,
371 PVOID arg2,
372 DWORD arg3,
373 PDWORD arg4,
374 LPOVERLAPPED arg5)
375{
376 BOOL rc;
377 HFILE hFile;
378
379 /* @@@PH 1998/02/12 Handle Manager support */
380 if (IS_HM_HANDLE(arg1))
381 return (HMReadFile(arg1, arg2, arg3, arg4, arg5));
382
383 /* @@@PH 1999/06/09 Handle Manager support */
384
385 /* @@@PH experimental Handlemanager support */
386 if (HMHandleTranslateToOS2(arg1,
387 &hFile) == NO_ERROR)
388 arg1 = hFile;
389
390 rc = O32_ReadFile(arg1,
391 arg2,
392 arg3,
393 arg4,
394 arg5);
395
396 dprintf(("KERNEL32: ReadFile %X %d bytes returned %d\n",
397 arg1,
398 arg3,
399 rc));
400
401 return(rc);
402}
403//******************************************************************************
404//******************************************************************************
405DWORD WIN32API SetFilePointer(HANDLE hFile,
406 LONG lDistanceToMove,
407 PLONG lpDistanceToMoveHigh,
408 DWORD dwMoveMethod)
409{
410 HANDLE hFile2;
411
412// dprintf(("KERNEL32: SetFilePointer\n"));
413
414 /* @@@PH experimental Handlemanager support */
415 if (HMHandleTranslateToOS2(hFile,
416 &hFile2) == NO_ERROR)
417 hFile = hFile2;
418
419 return(O32_SetFilePointer(hFile,
420 lDistanceToMove,
421 lpDistanceToMoveHigh,
422 dwMoveMethod));
423}
424//******************************************************************************
425//******************************************************************************
426BOOL WIN32API WriteFile(HANDLE hFile,
427 LPCVOID buffer,
428 DWORD nrbytes,
429 LPDWORD nrbyteswritten,
430 LPOVERLAPPED lpOverlapped)
431{
432 BOOL rc;
433 HANDLE hFile2;
434
435 //@@@PH translate handle
436 //KSO Aug 31 1998: when writing 0 bytes to a file win32 sets eof here.
437 if (nrbytes == 0 && !IS_HM_HANDLE(hFile))
438 {
439 *nrbyteswritten = 0;
440 return O32_SetEndOfFile(hFile);
441 }
442
443 /* @@@PH 1998/02/12 Handle Manager support */
444 if (IS_HM_HANDLE(hFile))
445 return (HMWriteFile(hFile,
446 buffer,
447 nrbytes,
448 nrbyteswritten,
449 lpOverlapped));
450
451 /* @@@PH experimental Handlemanager support */
452 if (HMHandleTranslateToOS2(hFile,
453 &hFile2) == NO_ERROR)
454 hFile = hFile2;
455
456
457 rc = O32_WriteFile(hFile, buffer, nrbytes, nrbyteswritten, (LPOVERLAPPED)lpOverlapped);
458 if(rc == 0 && GetLastError() == 436) { //ERROR_VIO_INVALID_HANDLE (OS/2)
459//// dprintf(("KERNEL32: WriteFile %s\n", buffer));
460 return(TRUE);
461 }
462 dprintf(("KERNEL32: WriteFile handle = %X, %d bytes, returned %d (%X)\n", hFile, nrbytes, rc, GetLastError()));
463 return(rc);
464}
465//******************************************************************************
466//******************************************************************************
467DWORD WIN32API SearchPathA( LPCSTR arg1, LPCSTR arg2, LPCSTR arg3, DWORD arg4, LPSTR arg5, LPSTR * arg6)
468{
469 dprintf(("KERNEL32: SearchPathA\n"));
470 return O32_SearchPath(arg1, arg2, arg3, arg4, arg5, arg6);
471}
472//******************************************************************************
473//******************************************************************************
474DWORD WIN32API SearchPathW(LPCWSTR lpPath, LPCWSTR lpFileName, LPCWSTR lpExtension,
475 DWORD nBufferLength, LPWSTR lpBuffer, LPWSTR *lpFilePart)
476{
477 char *asciipath, *asciifile, *asciiext, *asciibuffer, *asciipart;
478 DWORD rc;
479
480 dprintf(("KERNEL32: SearchPathW"));
481 asciibuffer = (char *)malloc(nBufferLength+1);
482 asciipath = UnicodeToAsciiString((LPWSTR)lpPath);
483 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
484 asciiext = UnicodeToAsciiString((LPWSTR)lpFileName);
485 rc = O32_SearchPath(asciipath, asciifile, asciiext, nBufferLength, asciibuffer, &asciipart);
486
487 if(rc) {
488 AsciiToUnicode(asciibuffer, lpBuffer);
489 *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
490 }
491 FreeAsciiString(asciiext);
492 FreeAsciiString(asciifile);
493 FreeAsciiString(asciipath);
494 free(asciibuffer);
495 return(rc);
496}
497//******************************************************************************
498//******************************************************************************
499DWORD WIN32API GetFileAttributesA(LPCSTR lpszFileName)
500{
501 DWORD rc;
502
503 rc = O32_GetFileAttributes((LPSTR)lpszFileName);
504 dprintf(("KERNEL32: GetFileAttributes of %s returned %d\n", lpszFileName, rc));
505 return(rc);
506}
507//******************************************************************************
508//******************************************************************************
509DWORD WIN32API GetFileAttributesW(LPCWSTR arg1)
510{
511 DWORD rc;
512 char *astring;
513
514 dprintf(("KERNEL32: GetFileAttributesW\n"));
515 astring = UnicodeToAsciiString((LPWSTR)arg1);
516 rc = O32_GetFileAttributes(astring);
517 FreeAsciiString(astring);
518 return(rc);
519}
520//******************************************************************************
521//******************************************************************************
522BOOL WIN32API SetFileAttributesA(LPCSTR arg1, DWORD arg2)
523{
524 dprintf(("KERNEL32: SetFileAttributes of %s\n", arg1));
525 return O32_SetFileAttributes(arg1, arg2);
526}
527//******************************************************************************
528//******************************************************************************
529BOOL WIN32API SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
530{
531 char *asciifile;
532 BOOL rc;
533
534 dprintf(("KERNEL32: SetFileAttributesW\n"));
535 asciifile = UnicodeToAsciiString((LPWSTR)lpFileName);
536 rc = O32_SetFileAttributes(asciifile, dwFileAttributes);
537 FreeAsciiString(asciifile);
538 return(rc);
539}
540//******************************************************************************
541//******************************************************************************
542DWORD WIN32API GetFullPathNameA(LPCSTR arg1, DWORD arg2, LPSTR arg3, LPSTR *arg4)
543{
544 dprintf(("KERNEL32: GetFullPathName %s\n", arg1));
545 return O32_GetFullPathName(arg1, arg2, arg3, arg4);
546}
547//******************************************************************************
548//******************************************************************************
549DWORD WIN32API GetFullPathNameW(LPCWSTR lpFileName, DWORD nBufferLength,
550 LPWSTR lpBuffer, LPWSTR *lpFilePart)
551{
552 char *astring, *asciibuffer, *asciipart;
553 DWORD rc;
554
555 dprintf(("KERNEL32: GetFullPathNameW\n"));
556 asciibuffer = (char *)malloc(nBufferLength+1);
557 astring = UnicodeToAsciiString((LPWSTR)lpFileName);
558
559 rc = O32_GetFullPathName(astring,
560 nBufferLength,
561 asciibuffer,
562 &asciipart);
563
564 dprintf(("KERNEL32: GetFullPathNameW %s returns %s\n",
565 astring,
566 asciibuffer));
567
568 if(rc)
569 AsciiToUnicode(asciibuffer,
570 lpBuffer);
571
572 *lpFilePart = lpBuffer + ((int)asciipart - (int)asciibuffer);
573
574 FreeAsciiString(astring);
575 free(asciibuffer);
576 return(rc);
577}
578//******************************************************************************
579//******************************************************************************
580BOOL WIN32API LockFile(HANDLE arg1,
581 DWORD arg2,
582 DWORD arg3,
583 DWORD arg4,
584 DWORD arg5)
585{
586 HFILE hFile;
587
588 /* @@@PH experimental Handlemanager support */
589 if (HMHandleTranslateToOS2(arg1,
590 &hFile) == NO_ERROR)
591 arg1 = hFile;
592
593 dprintf(("KERNEL32: LockFile (%08xh,%08xh,%08xh,%08xh,%08xh)\n",
594 arg1,
595 arg2,
596 arg3,
597 arg4,
598 arg5));
599
600 return O32_LockFile(arg1,
601 arg2,
602 arg3,
603 arg4,
604 arg5);
605}
606
607
608/*****************************************************************************
609 * Name : BOOL LockFileEx
610 * Purpose : The LockFileEx function locks a byte range within an open file for shared or exclusive access.
611 * Parameters: HANDLE hFile handle of file to lock
612 * DWORD dwFlags functional behavior modification flags
613 * DWORD dwReserved reserved, must be set to zero
614 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
615 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
616 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
617 * Variables :
618 * Result : TRUE / FALSE
619 * Remark :
620 * Status : UNTESTED STUB
621 *
622 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
623 *****************************************************************************/
624
625BOOL WIN32API LockFileEx(HANDLE hFile,
626 DWORD dwFlags,
627 DWORD dwReserved,
628 DWORD nNumberOfBytesToLockLow,
629 DWORD nNumberOfBytesToLockHigh,
630 LPOVERLAPPED LPOVERLAPPED)
631{
632 HFILE hFile2;
633
634 /* @@@PH experimental Handlemanager support */
635 if (HMHandleTranslateToOS2(hFile,
636 &hFile2) == NO_ERROR)
637 hFile = hFile2;
638
639 dprintf(("Kernel32: LockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
640 hFile,
641 dwFlags,
642 dwReserved,
643 nNumberOfBytesToLockLow,
644 nNumberOfBytesToLockHigh,
645 LPOVERLAPPED));
646
647 return(O32_LockFile(hFile,
648 LPOVERLAPPED->Offset,
649 LPOVERLAPPED->OffsetHigh,
650 nNumberOfBytesToLockLow,
651 nNumberOfBytesToLockHigh));
652}
653
654
655
656
657//******************************************************************************
658//******************************************************************************
659BOOL WIN32API MoveFileA( LPCSTR arg1, LPCSTR arg2)
660{
661 dprintf(("KERNEL32: MoveFileA\n"));
662 return O32_MoveFile(arg1, arg2);
663}
664//******************************************************************************
665//******************************************************************************
666BOOL WIN32API MoveFileExA(LPCSTR arg1,
667 LPCSTR arg2,
668 DWORD fdwFlags)
669{
670 dprintf(("KERNEL32: MoveFileExA %s to %s, not complete!\n", arg1, arg2));
671 return O32_MoveFile(arg1, arg2);
672}
673//******************************************************************************
674//******************************************************************************
675BOOL WIN32API MoveFileW(LPCWSTR lpSrc, LPCWSTR lpDest)
676{
677 char *asciisrc, *asciidest;
678 BOOL rc;
679
680 dprintf(("KERNEL32: MoveFileW\n"));
681 asciisrc = UnicodeToAsciiString((LPWSTR)lpSrc);
682 asciidest = UnicodeToAsciiString((LPWSTR)lpDest);
683 rc = O32_MoveFile(asciisrc, asciidest);
684 FreeAsciiString(asciisrc);
685 FreeAsciiString(asciidest);
686 return(rc);
687}
688//******************************************************************************
689//******************************************************************************
690BOOL WIN32API MoveFileExW(LPCWSTR arg1,
691 LPCWSTR arg2,
692 DWORD fdwFlags)
693{
694 dprintf(("KERNEL32: MoveFileExW %s to %s, not complete!\n", arg1, arg2));
695 return MoveFileW(arg1, arg2);
696}
697//******************************************************************************
698/*****************************************************************************
699 * Name : HFILE WIN32API OpenFile
700 * Purpose : forward OpenFile to Open32
701 * Parameters:
702 * Variables :
703 * Result : API returncode
704 * Remark : modified for handle translation support
705 * Status : @@@PH verify if 0 is a valid "invalid handle" :)
706 *
707 * Author : Patrick Haller [Fri, 1998/06/12 02:53]
708 *****************************************************************************/
709
710HFILE WIN32API OpenFile(LPCSTR arg1,
711 OFSTRUCT *arg2,
712 UINT arg3)
713{
714 HFILE hFile;
715 ULONG ulWindowsHandle; /* translated windows handle */
716
717 dprintf(("KERNEL32: OpenFile(%s, %08xh, %08xh)\n",
718 arg1,
719 arg2,
720 arg3));
721
722 hFile = O32_OpenFile(arg1, /* call open32 */
723 arg2,
724 arg3);
725
726 /* @@@PH 1999/06/09 HandleManager support temporarily disabled */
727 if (hFile != 0) /* check if handle is valid */
728 {
729 if (HMHandleAllocate(&ulWindowsHandle, /* allocate translation handle */
730 hFile) == NO_ERROR)
731 return (ulWindowsHandle);
732 }
733
734 return (hFile);
735}
736//******************************************************************************
737//******************************************************************************
738BOOL WIN32API UnlockFile(HANDLE arg1,
739 DWORD arg2,
740 DWORD arg3,
741 DWORD arg4,
742 DWORD arg5)
743{
744 HFILE hFile2;
745
746 /* @@@PH experimental Handlemanager support */
747 if (HMHandleTranslateToOS2(arg1,
748 &hFile2) == NO_ERROR)
749 arg1 = hFile2;
750
751 dprintf(("KERNEL32: UnlockFile(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
752 arg1,
753 arg2,
754 arg3,
755 arg4,
756 arg5));
757
758 return O32_UnlockFile(arg1,
759 arg2,
760 arg3,
761 arg4,
762 arg5);
763}
764
765
766/*****************************************************************************
767 * Name : BOOL UnlockFileEx
768 * Purpose : The UnlockFileEx function unlocks a previously locked byte range in an open file.
769 * Parameters: HANDLE hFile handle of file to lock
770 * DWORD dwReserved reserved, must be set to zero
771 * DWORD nNumberOfBytesToLockLow low-order 32 bits of length to lock
772 * DWORD nNumberOfBytesToLockHigh high-order 32 bits of length to lock
773 * LPOVERLAPPED LPOVERLAPPED addr. of structure with lock region start offset
774 * Variables :
775 * Result : TRUE / FALSE
776 * Remark :
777 * Status : UNTESTED STUB
778 *
779 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
780 *****************************************************************************/
781
782BOOL WIN32API UnlockFileEx(HANDLE hFile,
783 DWORD dwReserved,
784 DWORD nNumberOfBytesToLockLow,
785 DWORD nNumberOfBytesToLockHigh,
786 LPOVERLAPPED LPOVERLAPPED)
787{
788 HFILE hFile2;
789
790 /* @@@PH experimental Handlemanager support */
791 if (HMHandleTranslateToOS2(hFile,
792 &hFile2) == NO_ERROR)
793 hFile = hFile2;
794
795 dprintf(("Kernel32: UnlockFileEx(%08xh,%08xh,%08xh,%08xh,%08xh,%08xh)\n",
796 hFile,
797 dwReserved,
798 nNumberOfBytesToLockLow,
799 nNumberOfBytesToLockHigh,
800 LPOVERLAPPED));
801
802 return(O32_UnlockFile(hFile,
803 LPOVERLAPPED->Offset,
804 LPOVERLAPPED->OffsetHigh,
805 nNumberOfBytesToLockLow,
806 nNumberOfBytesToLockHigh));
807}
808//******************************************************************************
809//******************************************************************************
810DWORD WIN32API GetShortPathNameA(LPCTSTR lpszLongPath, LPTSTR lpszShortPath,
811 DWORD cchBuffer)
812{
813 int length;
814
815 dprintf(("KERNEL32: GetShortPathNameA of %s, just copying it\n", lpszLongPath));
816 length = strlen(lpszLongPath) + 1;
817 if(length > cchBuffer) {
818 *lpszShortPath = 0;
819 return(length);
820 }
821 memcpy(lpszShortPath, lpszLongPath, length);
822 return(length-1);
823}
824//******************************************************************************
825//******************************************************************************
826DWORD WIN32API GetShortPathNameW(LPCWSTR lpszLongPath, LPWSTR lpszShortPath,
827 DWORD cchBuffer)
828{
829 int length;
830
831 dprintf(("KERNEL32: GetShortPathNameW; just copying it\n"));
832 length = UniStrlen((UniChar*)lpszLongPath) + 1;
833 if(length > cchBuffer) {
834 *lpszShortPath = 0;
835 return(length);
836 }
837 memcpy(lpszShortPath, lpszLongPath, length*sizeof(USHORT));
838 return(length-1);
839}
840//******************************************************************************
841//******************************************************************************
842HANDLE WIN32API FindFirstChangeNotificationA(LPCSTR lpPathName, BOOL bWatchSubtree,
843 DWORD dwNotifyFilter)
844{
845 dprintf(("KERNEL32: FindFirstChangeNotificationA, Not implemented\n"));
846 return(0);
847}
848//******************************************************************************
849//******************************************************************************
850BOOL WIN32API FindNextChangeNotification(HANDLE hChange)
851{
852 dprintf(("KERNEL32: FindNextChangeNotification (%08xh), Not implemented\n",
853 hChange));
854
855 return(0);
856}
857//******************************************************************************
858//******************************************************************************
859VOID WIN32API SetFileApisToANSI( VOID ) /*PLF Tue 98-02-10 00:52:22*/
860{
861 dprintf(("SetFileApisToANSI() stub\n"));
862}
863
864/*****************************************************************************
865 * Name : DWORD GetCompressedFileSizeA
866 * Purpose : The GetCompressedFileSizeA function obtains the compressed
867 * size, in bytes, of a specified file.
868 * Parameters: LPCTSTR lpFileName, // pointer to name of file
869 * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
870 * high-order doubleword of file size
871 * Variables :
872 * Result : size of compressed file
873 * Remark :
874 * Status : UNTESTED
875 *
876 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
877 *****************************************************************************/
878
879DWORD WIN32API GetCompressedFileSizeA(LPCTSTR lpFileName,
880 LPDWORD lpFileSizeHigh)
881{
882 dprintf(("KERNEL32: GetCompressedFileSizeA (%s, %08xh) not implemented.\n",
883 lpFileName,
884 lpFileSizeHigh));
885
886 /* PH: simply return the standard filesize */
887 return 0;
888}
889
890
891/*****************************************************************************
892 * Name : DWORD GetCompressedFileSizeW
893 * Purpose : The GetCompressedFileSizeE function obtains the compressed
894 * size, in bytes, of a specified file.
895 * Parameters: LPCWSTR lpFileName, // pointer to name of file
896 * LPDWORD lpFileSizeHigh // pointer to DWORD to receive
897 * high-order doubleword of file size
898 * Variables :
899 * Result : size of compressed file
900 * Remark :
901 * Status : UNTESTED
902 *
903 * Author : Patrick Haller [Mon, 1998/06/15 08:00]
904 *****************************************************************************/
905
906DWORD WIN32API GetCompressedFileSizeW(LPCWSTR lpFileName,
907 LPDWORD lpFileSizeHigh)
908{
909 LPCTSTR lpAsciiFileName; /* converted filename */
910 DWORD rc; /* function result */
911
912 dprintf(("KERNEL32: GetCompressedFileSizeW (%s, %08xh)\n",
913 lpFileName,
914 lpFileSizeHigh));
915
916 lpAsciiFileName = UnicodeToAsciiString( (LPWSTR) lpFileName);
917
918 rc = GetCompressedFileSizeA(lpAsciiFileName,
919 lpFileSizeHigh);
920
921 FreeAsciiString( (char *) lpAsciiFileName);
922
923 return (rc); /* return result */
924}
Note: See TracBrowser for help on using the repository browser.