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

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

Fix: debug info

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