2 * File handling functions
4 * Copyright 1993 John Burton
5 * Copyright 1996 Alexandre Julliard
8 * Fix the CopyFileEx methods to implement the "extented" functionality.
9 * Right now, they simply call the CopyFile method.
21 #ifdef HAVE_SYS_ERRNO_H
22 #include <sys/errno.h>
24 #include <sys/types.h>
26 #ifdef HAVE_SYS_MMAN_H
37 #include "wine/winbase16.h"
38 #include "wine/winestring.h"
47 #include "debugtools.h"
51 DEFAULT_DEBUG_CHANNEL(file
);
53 #if defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
54 #define MAP_ANON MAP_ANONYMOUS
57 /* Size of per-process table of DOS handles */
58 #define DOS_TABLE_SIZE 256
60 static HANDLE dos_handles
[DOS_TABLE_SIZE
];
63 /***********************************************************************
66 * Convert OF_* mode into flags for CreateFile.
68 static void FILE_ConvertOFMode( INT mode
, DWORD
*access
, DWORD
*sharing
)
72 case OF_READ
: *access
= GENERIC_READ
; break;
73 case OF_WRITE
: *access
= GENERIC_WRITE
; break;
74 case OF_READWRITE
: *access
= GENERIC_READ
| GENERIC_WRITE
; break;
75 default: *access
= 0; break;
79 case OF_SHARE_EXCLUSIVE
: *sharing
= 0; break;
80 case OF_SHARE_DENY_WRITE
: *sharing
= FILE_SHARE_READ
; break;
81 case OF_SHARE_DENY_READ
: *sharing
= FILE_SHARE_WRITE
; break;
82 case OF_SHARE_DENY_NONE
:
84 default: *sharing
= FILE_SHARE_READ
| FILE_SHARE_WRITE
; break;
90 /***********************************************************************
94 * oldmode[I] mode how file was first opened
95 * mode[I] mode how the file should get opened
100 * Look what we have to do with the given SHARE modes
102 * Ralph Brown's interrupt list gives following explication, I guess
103 * the same holds for Windows, DENY ALL should be OF_SHARE_COMPAT
105 * FIXME: Validate this function
106 ========from Ralph Brown's list =========
108 Values of DOS file sharing behavior:
109 | Second and subsequent Opens
110 First |Compat Deny Deny Deny Deny
111 Open | All Write Read None
112 |R W RW R W RW R W RW R W RW R W RW
113 - - - - -| - - - - - - - - - - - - - - - - -
114 Compat R |Y Y Y N N N 1 N N N N N 1 N N
115 W |Y Y Y N N N N N N N N N N N N
116 RW|Y Y Y N N N N N N N N N N N N
118 Deny R |C C C N N N N N N N N N N N N
119 All W |C C C N N N N N N N N N N N N
120 RW|C C C N N N N N N N N N N N N
122 Deny R |2 C C N N N Y N N N N N Y N N
123 Write W |C C C N N N N N N Y N N Y N N
124 RW|C C C N N N N N N N N N Y N N
126 Deny R |C C C N N N N Y N N N N N Y N
127 Read W |C C C N N N N N N N Y N N Y N
128 RW|C C C N N N N N N N N N N Y N
130 Deny R |2 C C N N N Y Y Y N N N Y Y Y
131 None W |C C C N N N N N N Y Y Y Y Y Y
132 RW|C C C N N N N N N N N N Y Y Y
133 Legend: Y = open succeeds, N = open fails with error code 05h
134 C = open fails, INT 24 generated
135 1 = open succeeds if file read-only, else fails with error code
136 2 = open succeeds if file read-only, else fails with INT 24
137 ========end of description from Ralph Brown's List =====
138 For every "Y" in the table we return FALSE
139 For every "N" we set the DOS_ERROR and return TRUE
140 For all other cases we barf,set the DOS_ERROR and return TRUE
143 static BOOL
FILE_ShareDeny( int mode
, int oldmode
)
145 int oldsharemode
= oldmode
& 0x70;
146 int sharemode
= mode
& 0x70;
147 int oldopenmode
= oldmode
& 3;
148 int openmode
= mode
& 3;
150 switch (oldsharemode
)
152 case OF_SHARE_COMPAT
:
153 if (sharemode
== OF_SHARE_COMPAT
) return FALSE
;
154 if (openmode
== OF_READ
) goto test_ro_err05
;
156 case OF_SHARE_EXCLUSIVE
:
157 if (sharemode
== OF_SHARE_COMPAT
) goto fail_int24
;
159 case OF_SHARE_DENY_WRITE
:
160 if (openmode
!= OF_READ
)
162 if (sharemode
== OF_SHARE_COMPAT
) goto fail_int24
;
167 case OF_SHARE_COMPAT
:
168 if (oldopenmode
== OF_READ
) goto test_ro_int24
;
170 case OF_SHARE_DENY_NONE
:
172 case OF_SHARE_DENY_WRITE
:
173 if (oldopenmode
== OF_READ
) return FALSE
;
174 case OF_SHARE_DENY_READ
:
175 if (oldopenmode
== OF_WRITE
) return FALSE
;
176 case OF_SHARE_EXCLUSIVE
:
181 case OF_SHARE_DENY_READ
:
182 if (openmode
!= OF_WRITE
)
184 if (sharemode
== OF_SHARE_COMPAT
) goto fail_int24
;
189 case OF_SHARE_COMPAT
:
191 case OF_SHARE_DENY_NONE
:
193 case OF_SHARE_DENY_WRITE
:
194 if (oldopenmode
== OF_READ
) return FALSE
;
195 case OF_SHARE_DENY_READ
:
196 if (oldopenmode
== OF_WRITE
) return FALSE
;
197 case OF_SHARE_EXCLUSIVE
:
202 case OF_SHARE_DENY_NONE
:
205 case OF_SHARE_COMPAT
:
207 case OF_SHARE_DENY_NONE
:
209 case OF_SHARE_DENY_WRITE
:
210 if (oldopenmode
== OF_READ
) return FALSE
;
211 case OF_SHARE_DENY_READ
:
212 if (oldopenmode
== OF_WRITE
) return FALSE
;
213 case OF_SHARE_EXCLUSIVE
:
218 ERR("unknown mode\n");
220 ERR("shouldn't happen\n");
221 ERR("Please report to bon@elektron.ikp.physik.tu-darmstadt.de\n");
225 if (oldmode
== OF_READ
)
229 FIXME("generate INT24 missing\n");
230 /* Is this the right error? */
231 SetLastError( ERROR_ACCESS_DENIED
);
235 if (oldmode
== OF_READ
)
239 TRACE("Access Denied, oldmode 0x%02x mode 0x%02x\n",oldmode
,mode
);
240 SetLastError( ERROR_ACCESS_DENIED
);
246 /***********************************************************************
249 * Set the DOS error code from errno.
251 void FILE_SetDosError(void)
253 int save_errno
= errno
; /* errno gets overwritten by printf */
255 TRACE("errno = %d %s\n", errno
, strerror(errno
));
259 SetLastError( ERROR_SHARING_VIOLATION
);
262 SetLastError( ERROR_INVALID_HANDLE
);
265 SetLastError( ERROR_HANDLE_DISK_FULL
);
270 SetLastError( ERROR_ACCESS_DENIED
);
273 SetLastError( ERROR_LOCK_VIOLATION
);
276 SetLastError( ERROR_FILE_NOT_FOUND
);
279 SetLastError( ERROR_CANNOT_MAKE
);
283 SetLastError( ERROR_NO_MORE_FILES
);
286 SetLastError( ERROR_FILE_EXISTS
);
290 SetLastError( ERROR_SEEK
);
293 SetLastError( ERROR_DIR_NOT_EMPTY
);
296 SetLastError( ERROR_BAD_FORMAT
);
299 perror( "FILE_SetDosError: unknown errno" );
300 SetLastError( ERROR_GEN_FAILURE
);
307 /***********************************************************************
310 * Duplicate a Unix handle into a task handle.
312 HFILE
FILE_DupUnixHandle( int fd
, DWORD access
)
314 struct alloc_file_handle_request
*req
= get_req_buffer();
315 req
->access
= access
;
316 server_call_fd( REQ_ALLOC_FILE_HANDLE
, fd
, NULL
);
321 /***********************************************************************
324 * Implementation of CreateFile. Takes a Unix path name.
326 HANDLE
FILE_CreateFile( LPCSTR filename
, DWORD access
, DWORD sharing
,
327 LPSECURITY_ATTRIBUTES sa
, DWORD creation
,
328 DWORD attributes
, HANDLE
template, BOOL fail_read_only
)
331 struct create_file_request
*req
= get_req_buffer();
334 req
->access
= access
;
335 req
->inherit
= (sa
&& (sa
->nLength
>=sizeof(*sa
)) && sa
->bInheritHandle
);
336 req
->sharing
= sharing
;
337 req
->create
= creation
;
338 req
->attrs
= attributes
;
339 lstrcpynA( req
->name
, filename
, server_remaining(req
->name
) );
341 err
= server_call( REQ_CREATE_FILE
);
343 /* If write access failed, retry without GENERIC_WRITE */
345 if ((req
->handle
== -1) && !fail_read_only
&& (access
& GENERIC_WRITE
))
347 if ((err
== STATUS_MEDIA_WRITE_PROTECTED
) || (err
== STATUS_ACCESS_DENIED
))
349 TRACE("Write access failed for file '%s', trying without "
350 "write access\n", filename
);
351 access
&= ~GENERIC_WRITE
;
356 if (req
->handle
== -1)
357 WARN("Unable to create file '%s' (GLE %ld)\n", filename
,
364 /***********************************************************************
367 * Same as FILE_CreateFile but for a device
369 HFILE
FILE_CreateDevice( int client_id
, DWORD access
, LPSECURITY_ATTRIBUTES sa
)
371 struct create_device_request
*req
= get_req_buffer();
373 req
->access
= access
;
374 req
->inherit
= (sa
&& (sa
->nLength
>=sizeof(*sa
)) && sa
->bInheritHandle
);
377 server_call( REQ_CREATE_DEVICE
);
382 /*************************************************************************
383 * CreateFileA [KERNEL32.45] Creates or opens a file or other object
385 * Creates or opens an object, and returns a handle that can be used to
386 * access that object.
390 * filename [I] pointer to filename to be accessed
391 * access [I] access mode requested
392 * sharing [I] share mode
393 * sa [I] pointer to security attributes
394 * creation [I] how to create the file
395 * attributes [I] attributes for newly created file
396 * template [I] handle to file with extended attributes to copy
399 * Success: Open handle to specified file
400 * Failure: INVALID_HANDLE_VALUE
403 * Should call SetLastError() on failure.
407 * Doesn't support character devices, pipes, template files, or a
408 * lot of the 'attributes' flags yet.
410 HANDLE WINAPI
CreateFileA( LPCSTR filename
, DWORD access
, DWORD sharing
,
411 LPSECURITY_ATTRIBUTES sa
, DWORD creation
,
412 DWORD attributes
, HANDLE
template )
414 DOS_FULL_NAME full_name
;
418 SetLastError( ERROR_INVALID_PARAMETER
);
421 TRACE("%s %s%s%s%s%s%s%s\n",filename
,
422 ((access
& GENERIC_READ
)==GENERIC_READ
)?"GENERIC_READ ":"",
423 ((access
& GENERIC_WRITE
)==GENERIC_WRITE
)?"GENERIC_WRITE ":"",
424 (!access
)?"QUERY_ACCESS ":"",
425 ((sharing
& FILE_SHARE_READ
)==FILE_SHARE_READ
)?"FILE_SHARE_READ ":"",
426 ((sharing
& FILE_SHARE_WRITE
)==FILE_SHARE_WRITE
)?"FILE_SHARE_WRITE ":"",
427 ((sharing
& FILE_SHARE_DELETE
)==FILE_SHARE_DELETE
)?"FILE_SHARE_DELETE ":"",
428 (creation
==CREATE_NEW
)?"CREATE_NEW":
429 (creation
==CREATE_ALWAYS
)?"CREATE_ALWAYS ":
430 (creation
==OPEN_EXISTING
)?"OPEN_EXISTING ":
431 (creation
==OPEN_ALWAYS
)?"OPEN_ALWAYS ":
432 (creation
==TRUNCATE_EXISTING
)?"TRUNCATE_EXISTING ":"");
434 /* If the name starts with '\\?\', ignore the first 4 chars. */
435 if (!strncmp(filename
, "\\\\?\\", 4))
438 if (!strncmp(filename
, "UNC\\", 4))
440 FIXME("UNC name (%s) not supported.\n", filename
);
441 SetLastError( ERROR_PATH_NOT_FOUND
);
446 if (!strncmp(filename
, "\\\\.\\", 4)) {
447 if (!DOSFS_GetDevice( filename
))
448 return DEVICE_Open( filename
+4, access
, sa
);
450 filename
+=4; /* fall into DOSFS_Device case below */
453 /* If the name still starts with '\\', it's a UNC name. */
454 if (!strncmp(filename
, "\\\\", 2))
456 FIXME("UNC name (%s) not supported.\n", filename
);
457 SetLastError( ERROR_PATH_NOT_FOUND
);
461 /* If the name contains a DOS wild card (* or ?), do no create a file */
462 if(strchr(filename
,'*') || strchr(filename
,'?'))
465 /* Open a console for CONIN$ or CONOUT$ */
466 if (!strcasecmp(filename
, "CONIN$")) return CONSOLE_OpenHandle( FALSE
, access
, sa
);
467 if (!strcasecmp(filename
, "CONOUT$")) return CONSOLE_OpenHandle( TRUE
, access
, sa
);
469 if (DOSFS_GetDevice( filename
))
473 TRACE("opening device '%s'\n", filename
);
475 if (HFILE_ERROR
!=(ret
=DOSFS_OpenDevice( filename
, access
)))
478 /* Do not silence this please. It is a critical error. -MM */
479 ERR("Couldn't open device '%s'!\n",filename
);
480 SetLastError( ERROR_FILE_NOT_FOUND
);
484 /* check for filename, don't check for last entry if creating */
485 if (!DOSFS_GetFullName( filename
,
486 (creation
== OPEN_EXISTING
) ||
487 (creation
== TRUNCATE_EXISTING
),
489 WARN("Unable to get full filename from '%s' (GLE %ld)\n",
490 filename
, GetLastError());
494 return FILE_CreateFile( full_name
.long_name
, access
, sharing
,
495 sa
, creation
, attributes
, template,
496 DRIVE_GetFlags(full_name
.drive
) & DRIVE_FAIL_READ_ONLY
);
501 /*************************************************************************
502 * CreateFileW (KERNEL32.48)
504 HANDLE WINAPI
CreateFileW( LPCWSTR filename
, DWORD access
, DWORD sharing
,
505 LPSECURITY_ATTRIBUTES sa
, DWORD creation
,
506 DWORD attributes
, HANDLE
template)
508 LPSTR afn
= HEAP_strdupWtoA( GetProcessHeap(), 0, filename
);
509 HANDLE res
= CreateFileA( afn
, access
, sharing
, sa
, creation
, attributes
, template );
510 HeapFree( GetProcessHeap(), 0, afn
);
515 /***********************************************************************
518 * Fill a file information from a struct stat.
520 static void FILE_FillInfo( struct stat
*st
, BY_HANDLE_FILE_INFORMATION
*info
)
522 if (S_ISDIR(st
->st_mode
))
523 info
->dwFileAttributes
= FILE_ATTRIBUTE_DIRECTORY
;
525 info
->dwFileAttributes
= FILE_ATTRIBUTE_ARCHIVE
;
526 if (!(st
->st_mode
& S_IWUSR
))
527 info
->dwFileAttributes
|= FILE_ATTRIBUTE_READONLY
;
529 RtlSecondsSince1970ToTime( st
->st_mtime
, &info
->ftCreationTime
);
530 RtlSecondsSince1970ToTime( st
->st_mtime
, &info
->ftLastWriteTime
);
531 RtlSecondsSince1970ToTime( st
->st_atime
, &info
->ftLastAccessTime
);
533 info
->dwVolumeSerialNumber
= 0; /* FIXME */
534 info
->nFileSizeHigh
= 0;
535 info
->nFileSizeLow
= S_ISDIR(st
->st_mode
) ? 0 : st
->st_size
;
536 info
->nNumberOfLinks
= st
->st_nlink
;
537 info
->nFileIndexHigh
= 0;
538 info
->nFileIndexLow
= st
->st_ino
;
542 /***********************************************************************
545 * Stat a Unix path name. Return TRUE if OK.
547 BOOL
FILE_Stat( LPCSTR unixName
, BY_HANDLE_FILE_INFORMATION
*info
)
551 if (!unixName
|| !info
) return FALSE
;
553 if (stat( unixName
, &st
) == -1)
558 FILE_FillInfo( &st
, info
);
563 /***********************************************************************
564 * GetFileInformationByHandle (KERNEL32.219)
566 DWORD WINAPI
GetFileInformationByHandle( HANDLE hFile
,
567 BY_HANDLE_FILE_INFORMATION
*info
)
569 struct get_file_info_request
*req
= get_req_buffer();
573 if (server_call( REQ_GET_FILE_INFO
)) return 0;
574 RtlSecondsSince1970ToTime( req
->write_time
, &info
->ftCreationTime
);
575 RtlSecondsSince1970ToTime( req
->write_time
, &info
->ftLastWriteTime
);
576 RtlSecondsSince1970ToTime( req
->access_time
, &info
->ftLastAccessTime
);
577 info
->dwFileAttributes
= req
->attr
;
578 info
->dwVolumeSerialNumber
= req
->serial
;
579 info
->nFileSizeHigh
= req
->size_high
;
580 info
->nFileSizeLow
= req
->size_low
;
581 info
->nNumberOfLinks
= req
->links
;
582 info
->nFileIndexHigh
= req
->index_high
;
583 info
->nFileIndexLow
= req
->index_low
;
588 /**************************************************************************
589 * GetFileAttributes16 (KERNEL.420)
591 DWORD WINAPI
GetFileAttributes16( LPCSTR name
)
593 return GetFileAttributesA( name
);
597 /**************************************************************************
598 * GetFileAttributesA (KERNEL32.217)
600 DWORD WINAPI
GetFileAttributesA( LPCSTR name
)
602 DOS_FULL_NAME full_name
;
603 BY_HANDLE_FILE_INFORMATION info
;
605 if (name
== NULL
|| *name
=='\0') return -1;
607 if (!DOSFS_GetFullName( name
, TRUE
, &full_name
)) return -1;
608 if (!FILE_Stat( full_name
.long_name
, &info
)) return -1;
609 return info
.dwFileAttributes
;
613 /**************************************************************************
614 * GetFileAttributesW (KERNEL32.218)
616 DWORD WINAPI
GetFileAttributesW( LPCWSTR name
)
618 LPSTR nameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, name
);
619 DWORD res
= GetFileAttributesA( nameA
);
620 HeapFree( GetProcessHeap(), 0, nameA
);
625 /***********************************************************************
626 * GetFileSize (KERNEL32.220)
628 DWORD WINAPI
GetFileSize( HANDLE hFile
, LPDWORD filesizehigh
)
630 BY_HANDLE_FILE_INFORMATION info
;
631 if (!GetFileInformationByHandle( hFile
, &info
)) return 0;
632 if (filesizehigh
) *filesizehigh
= info
.nFileSizeHigh
;
633 return info
.nFileSizeLow
;
637 /***********************************************************************
638 * GetFileTime (KERNEL32.221)
640 BOOL WINAPI
GetFileTime( HANDLE hFile
, FILETIME
*lpCreationTime
,
641 FILETIME
*lpLastAccessTime
,
642 FILETIME
*lpLastWriteTime
)
644 BY_HANDLE_FILE_INFORMATION info
;
645 if (!GetFileInformationByHandle( hFile
, &info
)) return FALSE
;
646 if (lpCreationTime
) *lpCreationTime
= info
.ftCreationTime
;
647 if (lpLastAccessTime
) *lpLastAccessTime
= info
.ftLastAccessTime
;
648 if (lpLastWriteTime
) *lpLastWriteTime
= info
.ftLastWriteTime
;
652 /***********************************************************************
653 * CompareFileTime (KERNEL32.28)
655 INT WINAPI
CompareFileTime( LPFILETIME x
, LPFILETIME y
)
657 if (!x
|| !y
) return -1;
659 if (x
->dwHighDateTime
> y
->dwHighDateTime
)
661 if (x
->dwHighDateTime
< y
->dwHighDateTime
)
663 if (x
->dwLowDateTime
> y
->dwLowDateTime
)
665 if (x
->dwLowDateTime
< y
->dwLowDateTime
)
670 /***********************************************************************
671 * FILE_GetTempFileName : utility for GetTempFileName
673 static UINT
FILE_GetTempFileName( LPCSTR path
, LPCSTR prefix
, UINT unique
,
674 LPSTR buffer
, BOOL isWin16
)
676 static UINT unique_temp
;
677 DOS_FULL_NAME full_name
;
682 if ( !path
|| !prefix
|| !buffer
) return 0;
684 if (!unique_temp
) unique_temp
= time(NULL
) & 0xffff;
685 num
= unique
? (unique
& 0xffff) : (unique_temp
++ & 0xffff);
687 strcpy( buffer
, path
);
688 p
= buffer
+ strlen(buffer
);
690 /* add a \, if there isn't one and path is more than just the drive letter ... */
691 if ( !((strlen(buffer
) == 2) && (buffer
[1] == ':'))
692 && ((p
== buffer
) || (p
[-1] != '\\'))) *p
++ = '\\';
694 if (isWin16
) *p
++ = '~';
695 for (i
= 3; (i
> 0) && (*prefix
); i
--) *p
++ = *prefix
++;
696 sprintf( p
, "%04x.tmp", num
);
698 /* Now try to create it */
704 HFILE handle
= CreateFileA( buffer
, GENERIC_WRITE
, 0, NULL
,
705 CREATE_NEW
, FILE_ATTRIBUTE_NORMAL
, -1 );
706 if (handle
!= INVALID_HANDLE_VALUE
)
707 { /* We created it */
708 TRACE("created %s\n",
710 CloseHandle( handle
);
713 if (GetLastError() != ERROR_FILE_EXISTS
)
714 break; /* No need to go on */
716 sprintf( p
, "%04x.tmp", num
);
717 } while (num
!= (unique
& 0xffff));
720 /* Get the full path name */
722 if (DOSFS_GetFullName( buffer
, FALSE
, &full_name
))
724 /* Check if we have write access in the directory */
725 if ((p
= strrchr( full_name
.long_name
, '/' ))) *p
= '\0';
726 if (access( full_name
.long_name
, W_OK
) == -1)
727 WARN("returns '%s', which doesn't seem to be writeable.\n",
730 TRACE("returning %s\n", buffer
);
731 return unique
? unique
: num
;
735 /***********************************************************************
736 * GetTempFileNameA (KERNEL32.290)
738 UINT WINAPI
GetTempFileNameA( LPCSTR path
, LPCSTR prefix
, UINT unique
,
741 return FILE_GetTempFileName(path
, prefix
, unique
, buffer
, FALSE
);
744 /***********************************************************************
745 * GetTempFileNameW (KERNEL32.291)
747 UINT WINAPI
GetTempFileNameW( LPCWSTR path
, LPCWSTR prefix
, UINT unique
,
755 patha
= HEAP_strdupWtoA( GetProcessHeap(), 0, path
);
756 prefixa
= HEAP_strdupWtoA( GetProcessHeap(), 0, prefix
);
757 ret
= FILE_GetTempFileName( patha
, prefixa
, unique
, buffera
, FALSE
);
758 lstrcpyAtoW( buffer
, buffera
);
759 HeapFree( GetProcessHeap(), 0, patha
);
760 HeapFree( GetProcessHeap(), 0, prefixa
);
765 /***********************************************************************
766 * GetTempFileName16 (KERNEL.97)
768 UINT16 WINAPI
GetTempFileName16( BYTE drive
, LPCSTR prefix
, UINT16 unique
,
773 if (!(drive
& ~TF_FORCEDRIVE
)) /* drive 0 means current default drive */
774 drive
|= DRIVE_GetCurrentDrive() + 'A';
776 if ((drive
& TF_FORCEDRIVE
) &&
777 !DRIVE_IsValid( toupper(drive
& ~TF_FORCEDRIVE
) - 'A' ))
779 drive
&= ~TF_FORCEDRIVE
;
780 WARN("invalid drive %d specified\n", drive
);
783 if (drive
& TF_FORCEDRIVE
)
784 sprintf(temppath
,"%c:", drive
& ~TF_FORCEDRIVE
);
786 GetTempPathA( 132, temppath
);
787 return (UINT16
)FILE_GetTempFileName( temppath
, prefix
, unique
, buffer
, TRUE
);
790 /***********************************************************************
793 * Implementation of OpenFile16() and OpenFile32().
795 static HFILE
FILE_DoOpenFile( LPCSTR name
, OFSTRUCT
*ofs
, UINT mode
,
800 WORD filedatetime
[2];
801 DOS_FULL_NAME full_name
;
802 DWORD access
, sharing
;
805 if (!ofs
) return HFILE_ERROR
;
807 TRACE("%s %s %s %s%s%s%s%s%s%s%s%s\n",name
,
808 ((mode
& 0x3 )==OF_READ
)?"OF_READ":
809 ((mode
& 0x3 )==OF_WRITE
)?"OF_WRITE":
810 ((mode
& 0x3 )==OF_READWRITE
)?"OF_READWRITE":"unknown",
811 ((mode
& 0x70 )==OF_SHARE_COMPAT
)?"OF_SHARE_COMPAT":
812 ((mode
& 0x70 )==OF_SHARE_DENY_NONE
)?"OF_SHARE_DENY_NONE":
813 ((mode
& 0x70 )==OF_SHARE_DENY_READ
)?"OF_SHARE_DENY_READ":
814 ((mode
& 0x70 )==OF_SHARE_DENY_WRITE
)?"OF_SHARE_DENY_WRITE":
815 ((mode
& 0x70 )==OF_SHARE_EXCLUSIVE
)?"OF_SHARE_EXCLUSIVE":"unknown",
816 ((mode
& OF_PARSE
)==OF_PARSE
)?"OF_PARSE ":"",
817 ((mode
& OF_DELETE
)==OF_DELETE
)?"OF_DELETE ":"",
818 ((mode
& OF_VERIFY
)==OF_VERIFY
)?"OF_VERIFY ":"",
819 ((mode
& OF_SEARCH
)==OF_SEARCH
)?"OF_SEARCH ":"",
820 ((mode
& OF_CANCEL
)==OF_CANCEL
)?"OF_CANCEL ":"",
821 ((mode
& OF_CREATE
)==OF_CREATE
)?"OF_CREATE ":"",
822 ((mode
& OF_PROMPT
)==OF_PROMPT
)?"OF_PROMPT ":"",
823 ((mode
& OF_EXIST
)==OF_EXIST
)?"OF_EXIST ":"",
824 ((mode
& OF_REOPEN
)==OF_REOPEN
)?"OF_REOPEN ":""
828 ofs
->cBytes
= sizeof(OFSTRUCT
);
830 if (mode
& OF_REOPEN
) name
= ofs
->szPathName
;
833 ERR("called with `name' set to NULL ! Please debug.\n");
837 TRACE("%s %04x\n", name
, mode
);
839 /* the watcom 10.6 IDE relies on a valid path returned in ofs->szPathName
840 Are there any cases where getting the path here is wrong?
841 Uwe Bonnes 1997 Apr 2 */
842 if (!GetFullPathNameA( name
, sizeof(ofs
->szPathName
),
843 ofs
->szPathName
, NULL
)) goto error
;
844 FILE_ConvertOFMode( mode
, &access
, &sharing
);
846 /* OF_PARSE simply fills the structure */
850 ofs
->fFixedDisk
= (GetDriveType16( ofs
->szPathName
[0]-'A' )
852 TRACE("(%s): OF_PARSE, res = '%s'\n",
853 name
, ofs
->szPathName
);
857 /* OF_CREATE is completely different from all other options, so
860 if (mode
& OF_CREATE
)
862 if ((hFileRet
= CreateFileA( name
, GENERIC_READ
| GENERIC_WRITE
,
863 sharing
, NULL
, CREATE_ALWAYS
,
864 FILE_ATTRIBUTE_NORMAL
, -1 ))== INVALID_HANDLE_VALUE
)
869 /* If OF_SEARCH is set, ignore the given path */
871 if ((mode
& OF_SEARCH
) && !(mode
& OF_REOPEN
))
873 /* First try the file name as is */
874 if (DOSFS_GetFullName( name
, TRUE
, &full_name
)) goto found
;
875 /* Now remove the path */
876 if (name
[0] && (name
[1] == ':')) name
+= 2;
877 if ((p
= strrchr( name
, '\\' ))) name
= p
+ 1;
878 if ((p
= strrchr( name
, '/' ))) name
= p
+ 1;
879 if (!name
[0]) goto not_found
;
882 /* Now look for the file */
884 if (!DIR_SearchPath( NULL
, name
, NULL
, &full_name
, win32
)) goto not_found
;
887 TRACE("found %s = %s\n",
888 full_name
.long_name
, full_name
.short_name
);
889 lstrcpynA( ofs
->szPathName
, full_name
.short_name
,
890 sizeof(ofs
->szPathName
) );
892 if (mode
& OF_SHARE_EXCLUSIVE
)
893 /* Some InstallShield version uses OF_SHARE_EXCLUSIVE
894 on the file <tempdir>/_ins0432._mp to determine how
895 far installation has proceeded.
896 _ins0432._mp is an executable and while running the
897 application expects the open with OF_SHARE_ to fail*/
899 As our loader closes the files after loading the executable,
900 we can't find the running executable with FILE_InUse.
901 Perhaps the loader should keep the file open.
902 Recheck against how Win handles that case */
904 char *last
= strrchr(full_name
.long_name
,'/');
906 last
= full_name
.long_name
- 1;
907 if (GetModuleHandle16(last
+1))
909 TRACE("Denying shared open for %s\n",full_name
.long_name
);
914 if (mode
& OF_DELETE
)
916 if (unlink( full_name
.long_name
) == -1) goto not_found
;
917 TRACE("(%s): OF_DELETE return = OK\n", name
);
921 hFileRet
= FILE_CreateFile( full_name
.long_name
, access
, sharing
,
922 NULL
, OPEN_EXISTING
, 0, -1,
923 DRIVE_GetFlags(full_name
.drive
) & DRIVE_FAIL_READ_ONLY
);
924 if (hFileRet
== HFILE_ERROR
) goto not_found
;
926 GetFileTime( hFileRet
, NULL
, NULL
, &filetime
);
927 FileTimeToDosDateTime( &filetime
, &filedatetime
[0], &filedatetime
[1] );
928 if ((mode
& OF_VERIFY
) && (mode
& OF_REOPEN
))
930 if (memcmp( ofs
->reserved
, filedatetime
, sizeof(ofs
->reserved
) ))
932 CloseHandle( hFileRet
);
933 WARN("(%s): OF_VERIFY failed\n", name
);
934 /* FIXME: what error here? */
935 SetLastError( ERROR_FILE_NOT_FOUND
);
939 memcpy( ofs
->reserved
, filedatetime
, sizeof(ofs
->reserved
) );
941 success
: /* We get here if the open was successful */
942 TRACE("(%s): OK, return = %d\n", name
, hFileRet
);
945 if (mode
& OF_EXIST
) /* Return the handle, but close it first */
946 CloseHandle( hFileRet
);
950 hFileRet
= FILE_AllocDosHandle( hFileRet
);
951 if (hFileRet
== HFILE_ERROR16
) goto error
;
952 if (mode
& OF_EXIST
) /* Return the handle, but close it first */
953 _lclose16( hFileRet
);
957 not_found
: /* We get here if the file does not exist */
958 WARN("'%s' not found\n", name
);
959 SetLastError( ERROR_FILE_NOT_FOUND
);
962 error
: /* We get here if there was an error opening the file */
963 ofs
->nErrCode
= GetLastError();
964 WARN("(%s): return = HFILE_ERROR error= %d\n",
965 name
,ofs
->nErrCode
);
970 /***********************************************************************
971 * OpenFile16 (KERNEL.74)
973 HFILE16 WINAPI
OpenFile16( LPCSTR name
, OFSTRUCT
*ofs
, UINT16 mode
)
975 return FILE_DoOpenFile( name
, ofs
, mode
, FALSE
);
979 /***********************************************************************
980 * OpenFile (KERNEL32.396)
982 HFILE WINAPI
OpenFile( LPCSTR name
, OFSTRUCT
*ofs
, UINT mode
)
984 return FILE_DoOpenFile( name
, ofs
, mode
, TRUE
);
988 /***********************************************************************
989 * FILE_InitProcessDosHandles
991 * Allocates the default DOS handles for a process. Called either by
992 * AllocDosHandle below or by the DOSVM stuff.
994 static void FILE_InitProcessDosHandles( void )
996 dos_handles
[0] = GetStdHandle(STD_INPUT_HANDLE
);
997 dos_handles
[1] = GetStdHandle(STD_OUTPUT_HANDLE
);
998 dos_handles
[2] = GetStdHandle(STD_ERROR_HANDLE
);
999 dos_handles
[3] = GetStdHandle(STD_ERROR_HANDLE
);
1000 dos_handles
[4] = GetStdHandle(STD_ERROR_HANDLE
);
1003 /***********************************************************************
1004 * FILE_AllocDosHandle
1006 * Allocate a DOS handle for a Win32 handle. The Win32 handle is no
1007 * longer valid after this function (even on failure).
1009 HFILE16
FILE_AllocDosHandle( HANDLE handle
)
1013 if (!handle
|| (handle
== INVALID_HANDLE_VALUE
))
1014 return INVALID_HANDLE_VALUE16
;
1016 for (i
= 5; i
< DOS_TABLE_SIZE
; i
++)
1017 if (!dos_handles
[i
])
1019 dos_handles
[i
] = handle
;
1020 TRACE("Got %d for h32 %d\n", i
, handle
);
1023 CloseHandle( handle
);
1024 SetLastError( ERROR_TOO_MANY_OPEN_FILES
);
1025 return INVALID_HANDLE_VALUE16
;
1029 /***********************************************************************
1032 * Return the Win32 handle for a DOS handle.
1034 HANDLE
FILE_GetHandle( HFILE16 hfile
)
1036 if (hfile
< 5 && !dos_handles
[hfile
]) FILE_InitProcessDosHandles();
1037 if ((hfile
>= DOS_TABLE_SIZE
) || !dos_handles
[hfile
])
1039 SetLastError( ERROR_INVALID_HANDLE
);
1040 return INVALID_HANDLE_VALUE
;
1042 return dos_handles
[hfile
];
1046 /***********************************************************************
1049 * dup2() function for DOS handles.
1051 HFILE16
FILE_Dup2( HFILE16 hFile1
, HFILE16 hFile2
)
1055 if (hFile1
< 5 && !dos_handles
[hFile1
]) FILE_InitProcessDosHandles();
1057 if ((hFile1
>= DOS_TABLE_SIZE
) || (hFile2
>= DOS_TABLE_SIZE
) || !dos_handles
[hFile1
])
1059 SetLastError( ERROR_INVALID_HANDLE
);
1060 return HFILE_ERROR16
;
1064 FIXME("stdio handle closed, need proper conversion\n" );
1065 SetLastError( ERROR_INVALID_HANDLE
);
1066 return HFILE_ERROR16
;
1068 if (!DuplicateHandle( GetCurrentProcess(), dos_handles
[hFile1
],
1069 GetCurrentProcess(), &new_handle
,
1070 0, FALSE
, DUPLICATE_SAME_ACCESS
))
1071 return HFILE_ERROR16
;
1072 if (dos_handles
[hFile2
]) CloseHandle( dos_handles
[hFile2
] );
1073 dos_handles
[hFile2
] = new_handle
;
1078 /***********************************************************************
1079 * _lclose16 (KERNEL.81)
1081 HFILE16 WINAPI
_lclose16( HFILE16 hFile
)
1085 FIXME("stdio handle closed, need proper conversion\n" );
1086 SetLastError( ERROR_INVALID_HANDLE
);
1087 return HFILE_ERROR16
;
1089 if ((hFile
>= DOS_TABLE_SIZE
) || !dos_handles
[hFile
])
1091 SetLastError( ERROR_INVALID_HANDLE
);
1092 return HFILE_ERROR16
;
1094 TRACE("%d (handle32=%d)\n", hFile
, dos_handles
[hFile
] );
1095 CloseHandle( dos_handles
[hFile
] );
1096 dos_handles
[hFile
] = 0;
1101 /***********************************************************************
1102 * _lclose (KERNEL32.592)
1104 HFILE WINAPI
_lclose( HFILE hFile
)
1106 TRACE("handle %d\n", hFile
);
1107 return CloseHandle( hFile
) ? 0 : HFILE_ERROR
;
1110 /***********************************************************************
1111 * GetOverlappedResult (KERNEL32.360)
1113 BOOL WINAPI
GetOverlappedResult(HANDLE hFile
,LPOVERLAPPED lpOverlapped
,
1114 LPDWORD lpNumberOfBytesTransferred
,
1117 /* Since all i/o is currently synchronous,
1118 * return true, assuming ReadFile/WriteFile
1119 * have completed the operation */
1120 FIXME("NO Asynch I/O, assuming Read/Write succeeded\n" );
1124 /***********************************************************************
1125 * ReadFile (KERNEL32.428)
1127 BOOL WINAPI
ReadFile( HANDLE hFile
, LPVOID buffer
, DWORD bytesToRead
,
1128 LPDWORD bytesRead
, LPOVERLAPPED overlapped
)
1130 struct get_read_fd_request
*req
= get_req_buffer();
1131 int unix_handle
, result
;
1133 TRACE("%d %p %ld\n", hFile
, buffer
, bytesToRead
);
1135 if (bytesRead
) *bytesRead
= 0; /* Do this before anything else */
1136 if (!bytesToRead
) return TRUE
;
1139 SetLastError ( ERROR_INVALID_PARAMETER
);
1143 req
->handle
= hFile
;
1144 server_call_fd( REQ_GET_READ_FD
, -1, &unix_handle
);
1145 if (unix_handle
== -1) return FALSE
;
1146 while ((result
= read( unix_handle
, buffer
, bytesToRead
)) == -1)
1148 if ((errno
== EAGAIN
) || (errno
== EINTR
)) continue;
1149 if ((errno
== EFAULT
) && !VIRTUAL_HandleFault( buffer
)) continue;
1153 close( unix_handle
);
1154 if (result
== -1) return FALSE
;
1155 if (bytesRead
) *bytesRead
= result
;
1160 /***********************************************************************
1161 * WriteFile (KERNEL32.578)
1163 BOOL WINAPI
WriteFile( HANDLE hFile
, LPCVOID buffer
, DWORD bytesToWrite
,
1164 LPDWORD bytesWritten
, LPOVERLAPPED overlapped
)
1166 struct get_write_fd_request
*req
= get_req_buffer();
1167 int unix_handle
, result
;
1169 TRACE("%d %p %ld\n", hFile
, buffer
, bytesToWrite
);
1171 if (bytesWritten
) *bytesWritten
= 0; /* Do this before anything else */
1172 if (!bytesToWrite
) return TRUE
;
1175 SetLastError ( ERROR_INVALID_PARAMETER
);
1179 req
->handle
= hFile
;
1180 server_call_fd( REQ_GET_WRITE_FD
, -1, &unix_handle
);
1181 if (unix_handle
== -1) return FALSE
;
1182 while ((result
= write( unix_handle
, buffer
, bytesToWrite
)) == -1)
1184 if ((errno
== EAGAIN
) || (errno
== EINTR
)) continue;
1185 if ((errno
== EFAULT
) && !VIRTUAL_HandleFault( buffer
)) continue;
1186 if (errno
== ENOSPC
)
1187 SetLastError( ERROR_DISK_FULL
);
1192 close( unix_handle
);
1193 if (result
== -1) return FALSE
;
1194 if (bytesWritten
) *bytesWritten
= result
;
1199 /***********************************************************************
1202 LONG WINAPI
WIN16_hread( HFILE16 hFile
, SEGPTR buffer
, LONG count
)
1206 TRACE("%d %08lx %ld\n",
1207 hFile
, (DWORD
)buffer
, count
);
1209 /* Some programs pass a count larger than the allocated buffer */
1210 maxlen
= GetSelectorLimit16( SELECTOROF(buffer
) ) - OFFSETOF(buffer
) + 1;
1211 if (count
> maxlen
) count
= maxlen
;
1212 return _lread(FILE_GetHandle(hFile
), PTR_SEG_TO_LIN(buffer
), count
);
1216 /***********************************************************************
1219 UINT16 WINAPI
WIN16_lread( HFILE16 hFile
, SEGPTR buffer
, UINT16 count
)
1221 return (UINT16
)WIN16_hread( hFile
, buffer
, (LONG
)count
);
1225 /***********************************************************************
1226 * _lread (KERNEL32.596)
1228 UINT WINAPI
_lread( HFILE handle
, LPVOID buffer
, UINT count
)
1231 if (!ReadFile( handle
, buffer
, count
, &result
, NULL
)) return -1;
1236 /***********************************************************************
1237 * _lread16 (KERNEL.82)
1239 UINT16 WINAPI
_lread16( HFILE16 hFile
, LPVOID buffer
, UINT16 count
)
1241 return (UINT16
)_lread(FILE_GetHandle(hFile
), buffer
, (LONG
)count
);
1245 /***********************************************************************
1246 * _lcreat16 (KERNEL.83)
1248 HFILE16 WINAPI
_lcreat16( LPCSTR path
, INT16 attr
)
1250 return FILE_AllocDosHandle( _lcreat( path
, attr
) );
1254 /***********************************************************************
1255 * _lcreat (KERNEL32.593)
1257 HFILE WINAPI
_lcreat( LPCSTR path
, INT attr
)
1259 /* Mask off all flags not explicitly allowed by the doc */
1260 attr
&= FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
| FILE_ATTRIBUTE_SYSTEM
;
1261 TRACE("%s %02x\n", path
, attr
);
1262 return CreateFileA( path
, GENERIC_READ
| GENERIC_WRITE
,
1263 FILE_SHARE_READ
| FILE_SHARE_WRITE
, NULL
,
1264 CREATE_ALWAYS
, attr
, -1 );
1268 /***********************************************************************
1269 * SetFilePointer (KERNEL32.492)
1271 DWORD WINAPI
SetFilePointer( HANDLE hFile
, LONG distance
, LONG
*highword
,
1274 struct set_file_pointer_request
*req
= get_req_buffer();
1277 ((distance
>= 0 && *highword
!= 0) || (distance
< 0 && *highword
!= -1)))
1279 FIXME("64-bit offsets not supported yet\n"
1280 "SetFilePointer(%08x,%08lx,%08lx,%08lx)\n",
1281 hFile
,distance
,*highword
,method
);
1282 SetLastError( ERROR_INVALID_PARAMETER
);
1285 TRACE("handle %d offset %ld origin %ld\n",
1286 hFile
, distance
, method
);
1288 req
->handle
= hFile
;
1289 req
->low
= distance
;
1290 req
->high
= highword
? *highword
: (distance
>= 0) ? 0 : -1;
1291 /* FIXME: assumes 1:1 mapping between Windows and Unix seek constants */
1292 req
->whence
= method
;
1294 if (server_call( REQ_SET_FILE_POINTER
)) return 0xffffffff;
1295 if (highword
) *highword
= req
->new_high
;
1296 return req
->new_low
;
1300 /***********************************************************************
1301 * _llseek16 (KERNEL.84)
1304 * Seeking before the start of the file should be allowed for _llseek16,
1305 * but cause subsequent I/O operations to fail (cf. interrupt list)
1308 LONG WINAPI
_llseek16( HFILE16 hFile
, LONG lOffset
, INT16 nOrigin
)
1310 return SetFilePointer( FILE_GetHandle(hFile
), lOffset
, NULL
, nOrigin
);
1314 /***********************************************************************
1315 * _llseek (KERNEL32.594)
1317 LONG WINAPI
_llseek( HFILE hFile
, LONG lOffset
, INT nOrigin
)
1319 return SetFilePointer( hFile
, lOffset
, NULL
, nOrigin
);
1323 /***********************************************************************
1324 * _lopen16 (KERNEL.85)
1326 HFILE16 WINAPI
_lopen16( LPCSTR path
, INT16 mode
)
1328 return FILE_AllocDosHandle( _lopen( path
, mode
) );
1332 /***********************************************************************
1333 * _lopen (KERNEL32.595)
1335 HFILE WINAPI
_lopen( LPCSTR path
, INT mode
)
1337 DWORD access
, sharing
;
1339 TRACE("('%s',%04x)\n", path
, mode
);
1340 FILE_ConvertOFMode( mode
, &access
, &sharing
);
1341 return CreateFileA( path
, access
, sharing
, NULL
, OPEN_EXISTING
, 0, -1 );
1345 /***********************************************************************
1346 * _lwrite16 (KERNEL.86)
1348 UINT16 WINAPI
_lwrite16( HFILE16 hFile
, LPCSTR buffer
, UINT16 count
)
1350 return (UINT16
)_hwrite( FILE_GetHandle(hFile
), buffer
, (LONG
)count
);
1353 /***********************************************************************
1354 * _lwrite (KERNEL32.761)
1356 UINT WINAPI
_lwrite( HFILE hFile
, LPCSTR buffer
, UINT count
)
1358 return (UINT
)_hwrite( hFile
, buffer
, (LONG
)count
);
1362 /***********************************************************************
1363 * _hread16 (KERNEL.349)
1365 LONG WINAPI
_hread16( HFILE16 hFile
, LPVOID buffer
, LONG count
)
1367 return _lread( FILE_GetHandle(hFile
), buffer
, count
);
1371 /***********************************************************************
1372 * _hread (KERNEL32.590)
1374 LONG WINAPI
_hread( HFILE hFile
, LPVOID buffer
, LONG count
)
1376 return _lread( hFile
, buffer
, count
);
1380 /***********************************************************************
1381 * _hwrite16 (KERNEL.350)
1383 LONG WINAPI
_hwrite16( HFILE16 hFile
, LPCSTR buffer
, LONG count
)
1385 return _hwrite( FILE_GetHandle(hFile
), buffer
, count
);
1389 /***********************************************************************
1390 * _hwrite (KERNEL32.591)
1392 * experimentation yields that _lwrite:
1393 * o truncates the file at the current position with
1395 * o returns 0 on a 0 length write
1396 * o works with console handles
1399 LONG WINAPI
_hwrite( HFILE handle
, LPCSTR buffer
, LONG count
)
1403 TRACE("%d %p %ld\n", handle
, buffer
, count
);
1407 /* Expand or truncate at current position */
1408 if (!SetEndOfFile( handle
)) return HFILE_ERROR
;
1411 if (!WriteFile( handle
, buffer
, count
, &result
, NULL
))
1417 /***********************************************************************
1418 * SetHandleCount16 (KERNEL.199)
1420 UINT16 WINAPI
SetHandleCount16( UINT16 count
)
1422 HGLOBAL16 hPDB
= GetCurrentPDB16();
1423 PDB16
*pdb
= (PDB16
*)GlobalLock16( hPDB
);
1424 BYTE
*files
= PTR_SEG_TO_LIN( pdb
->fileHandlesPtr
);
1426 TRACE("(%d)\n", count
);
1428 if (count
< 20) count
= 20; /* No point in going below 20 */
1429 else if (count
> 254) count
= 254;
1433 if (pdb
->nbFiles
> 20)
1435 memcpy( pdb
->fileHandles
, files
, 20 );
1436 GlobalFree16( pdb
->hFileHandles
);
1437 pdb
->fileHandlesPtr
= (SEGPTR
)MAKELONG( 0x18,
1438 GlobalHandleToSel16( hPDB
) );
1439 pdb
->hFileHandles
= 0;
1443 else /* More than 20, need a new file handles table */
1446 HGLOBAL16 newhandle
= GlobalAlloc16( GMEM_MOVEABLE
, count
);
1449 SetLastError( ERROR_NOT_ENOUGH_MEMORY
);
1450 return pdb
->nbFiles
;
1452 newfiles
= (BYTE
*)GlobalLock16( newhandle
);
1454 if (count
> pdb
->nbFiles
)
1456 memcpy( newfiles
, files
, pdb
->nbFiles
);
1457 memset( newfiles
+ pdb
->nbFiles
, 0xff, count
- pdb
->nbFiles
);
1459 else memcpy( newfiles
, files
, count
);
1460 if (pdb
->nbFiles
> 20) GlobalFree16( pdb
->hFileHandles
);
1461 pdb
->fileHandlesPtr
= WIN16_GlobalLock16( newhandle
);
1462 pdb
->hFileHandles
= newhandle
;
1463 pdb
->nbFiles
= count
;
1465 return pdb
->nbFiles
;
1469 /*************************************************************************
1470 * SetHandleCount (KERNEL32.494)
1472 UINT WINAPI
SetHandleCount( UINT count
)
1474 return min( 256, count
);
1478 /***********************************************************************
1479 * FlushFileBuffers (KERNEL32.133)
1481 BOOL WINAPI
FlushFileBuffers( HANDLE hFile
)
1483 struct flush_file_request
*req
= get_req_buffer();
1484 req
->handle
= hFile
;
1485 return !server_call( REQ_FLUSH_FILE
);
1489 /**************************************************************************
1490 * SetEndOfFile (KERNEL32.483)
1492 BOOL WINAPI
SetEndOfFile( HANDLE hFile
)
1494 struct truncate_file_request
*req
= get_req_buffer();
1495 req
->handle
= hFile
;
1496 return !server_call( REQ_TRUNCATE_FILE
);
1500 /***********************************************************************
1501 * DeleteFile16 (KERNEL.146)
1503 BOOL16 WINAPI
DeleteFile16( LPCSTR path
)
1505 return DeleteFileA( path
);
1509 /***********************************************************************
1510 * DeleteFileA (KERNEL32.71)
1512 BOOL WINAPI
DeleteFileA( LPCSTR path
)
1514 DOS_FULL_NAME full_name
;
1516 TRACE("'%s'\n", path
);
1520 ERR("Empty path passed\n");
1523 if (DOSFS_GetDevice( path
))
1525 WARN("cannot remove DOS device '%s'!\n", path
);
1526 SetLastError( ERROR_FILE_NOT_FOUND
);
1530 if (!DOSFS_GetFullName( path
, TRUE
, &full_name
)) return FALSE
;
1531 if (unlink( full_name
.long_name
) == -1)
1540 /***********************************************************************
1541 * DeleteFileW (KERNEL32.72)
1543 BOOL WINAPI
DeleteFileW( LPCWSTR path
)
1545 LPSTR xpath
= HEAP_strdupWtoA( GetProcessHeap(), 0, path
);
1546 BOOL ret
= DeleteFileA( xpath
);
1547 HeapFree( GetProcessHeap(), 0, xpath
);
1552 /***********************************************************************
1555 LPVOID
FILE_dommap( int unix_handle
, LPVOID start
,
1556 DWORD size_high
, DWORD size_low
,
1557 DWORD offset_high
, DWORD offset_low
,
1558 int prot
, int flags
)
1564 if (size_high
|| offset_high
)
1565 FIXME("offsets larger than 4Gb not supported\n");
1567 if (unix_handle
== -1)
1572 static int fdzero
= -1;
1576 if ((fdzero
= open( "/dev/zero", O_RDONLY
)) == -1)
1578 perror( "/dev/zero: open" );
1583 #endif /* MAP_ANON */
1584 /* Linux EINVAL's on us if we don't pass MAP_PRIVATE to an anon mmap */
1586 flags
&= ~MAP_SHARED
;
1589 flags
|= MAP_PRIVATE
;
1592 else fd
= unix_handle
;
1594 if ((ret
= mmap( start
, size_low
, prot
,
1595 flags
, fd
, offset_low
)) != (LPVOID
)-1)
1598 /* mmap() failed; if this is because the file offset is not */
1599 /* page-aligned (EINVAL), or because the underlying filesystem */
1600 /* does not support mmap() (ENOEXEC,ENODEV), we do it by hand. */
1602 if (unix_handle
== -1) return ret
;
1603 if ((errno
!= ENOEXEC
) && (errno
!= EINVAL
) && (errno
!= ENODEV
)) return ret
;
1604 if (prot
& PROT_WRITE
)
1606 /* We cannot fake shared write mappings */
1608 if (flags
& MAP_SHARED
) return ret
;
1611 if (!(flags
& MAP_PRIVATE
)) return ret
;
1614 /* printf( "FILE_mmap: mmap failed (%d), faking it\n", errno );*/
1615 /* Reserve the memory with an anonymous mmap */
1616 ret
= FILE_dommap( -1, start
, size_high
, size_low
, 0, 0,
1617 PROT_READ
| PROT_WRITE
, flags
);
1618 if (ret
== (LPVOID
)-1) return ret
;
1619 /* Now read in the file */
1620 if ((pos
= lseek( fd
, offset_low
, SEEK_SET
)) == -1)
1622 FILE_munmap( ret
, size_high
, size_low
);
1625 read( fd
, ret
, size_low
);
1626 lseek( fd
, pos
, SEEK_SET
); /* Restore the file pointer */
1627 mprotect( ret
, size_low
, prot
); /* Set the right protection */
1632 /***********************************************************************
1635 int FILE_munmap( LPVOID start
, DWORD size_high
, DWORD size_low
)
1638 FIXME("offsets larger than 4Gb not supported\n");
1639 return munmap( start
, size_low
);
1643 /***********************************************************************
1644 * GetFileType (KERNEL32.222)
1646 DWORD WINAPI
GetFileType( HANDLE hFile
)
1648 struct get_file_info_request
*req
= get_req_buffer();
1649 req
->handle
= hFile
;
1650 if (server_call( REQ_GET_FILE_INFO
)) return FILE_TYPE_UNKNOWN
;
1655 /**************************************************************************
1656 * MoveFileExA (KERNEL32.???)
1658 BOOL WINAPI
MoveFileExA( LPCSTR fn1
, LPCSTR fn2
, DWORD flag
)
1660 DOS_FULL_NAME full_name1
, full_name2
;
1662 TRACE("(%s,%s,%04lx)\n", fn1
, fn2
, flag
);
1664 if (!DOSFS_GetFullName( fn1
, TRUE
, &full_name1
)) return FALSE
;
1666 if (fn2
) /* !fn2 means delete fn1 */
1668 if (DOSFS_GetFullName( fn2
, TRUE
, &full_name2
))
1670 /* target exists, check if we may overwrite */
1671 if (!(flag
& MOVEFILE_REPLACE_EXISTING
))
1673 /* FIXME: Use right error code */
1674 SetLastError( ERROR_ACCESS_DENIED
);
1678 else if (!DOSFS_GetFullName( fn2
, FALSE
, &full_name2
)) return FALSE
;
1680 /* Source name and target path are valid */
1682 if (flag
& MOVEFILE_DELAY_UNTIL_REBOOT
)
1684 /* FIXME: (bon@elektron.ikp.physik.th-darmstadt.de 970706)
1685 Perhaps we should queue these command and execute it
1686 when exiting... What about using on_exit(2)
1688 FIXME("Please move existing file '%s' to file '%s' when Wine has finished\n",
1689 full_name1
.long_name
, full_name2
.long_name
);
1693 if (full_name1
.drive
!= full_name2
.drive
)
1695 /* use copy, if allowed */
1696 if (!(flag
& MOVEFILE_COPY_ALLOWED
))
1698 /* FIXME: Use right error code */
1699 SetLastError( ERROR_FILE_EXISTS
);
1702 return CopyFileA( fn1
, fn2
, !(flag
& MOVEFILE_REPLACE_EXISTING
) );
1704 if (rename( full_name1
.long_name
, full_name2
.long_name
) == -1)
1711 else /* fn2 == NULL means delete source */
1713 if (flag
& MOVEFILE_DELAY_UNTIL_REBOOT
)
1715 if (flag
& MOVEFILE_COPY_ALLOWED
) {
1716 WARN("Illegal flag\n");
1717 SetLastError( ERROR_GEN_FAILURE
);
1720 /* FIXME: (bon@elektron.ikp.physik.th-darmstadt.de 970706)
1721 Perhaps we should queue these command and execute it
1722 when exiting... What about using on_exit(2)
1724 FIXME("Please delete file '%s' when Wine has finished\n",
1725 full_name1
.long_name
);
1729 if (unlink( full_name1
.long_name
) == -1)
1734 return TRUE
; /* successfully deleted */
1738 /**************************************************************************
1739 * MoveFileExW (KERNEL32.???)
1741 BOOL WINAPI
MoveFileExW( LPCWSTR fn1
, LPCWSTR fn2
, DWORD flag
)
1743 LPSTR afn1
= HEAP_strdupWtoA( GetProcessHeap(), 0, fn1
);
1744 LPSTR afn2
= HEAP_strdupWtoA( GetProcessHeap(), 0, fn2
);
1745 BOOL res
= MoveFileExA( afn1
, afn2
, flag
);
1746 HeapFree( GetProcessHeap(), 0, afn1
);
1747 HeapFree( GetProcessHeap(), 0, afn2
);
1752 /**************************************************************************
1753 * MoveFileA (KERNEL32.387)
1755 * Move file or directory
1757 BOOL WINAPI
MoveFileA( LPCSTR fn1
, LPCSTR fn2
)
1759 DOS_FULL_NAME full_name1
, full_name2
;
1762 TRACE("(%s,%s)\n", fn1
, fn2
);
1764 if (!DOSFS_GetFullName( fn1
, TRUE
, &full_name1
)) return FALSE
;
1765 if (DOSFS_GetFullName( fn2
, TRUE
, &full_name2
))
1766 /* The new name must not already exist */
1768 if (!DOSFS_GetFullName( fn2
, FALSE
, &full_name2
)) return FALSE
;
1770 if (full_name1
.drive
== full_name2
.drive
) /* move */
1771 if (rename( full_name1
.long_name
, full_name2
.long_name
) == -1)
1778 if (stat( full_name1
.long_name
, &fstat
))
1780 WARN("Invalid source file %s\n",
1781 full_name1
.long_name
);
1785 if (S_ISDIR(fstat
.st_mode
)) {
1786 /* No Move for directories across file systems */
1787 /* FIXME: Use right error code */
1788 SetLastError( ERROR_GEN_FAILURE
);
1792 return CopyFileA(fn1
, fn2
, TRUE
); /*fail, if exist */
1797 /**************************************************************************
1798 * MoveFileW (KERNEL32.390)
1800 BOOL WINAPI
MoveFileW( LPCWSTR fn1
, LPCWSTR fn2
)
1802 LPSTR afn1
= HEAP_strdupWtoA( GetProcessHeap(), 0, fn1
);
1803 LPSTR afn2
= HEAP_strdupWtoA( GetProcessHeap(), 0, fn2
);
1804 BOOL res
= MoveFileA( afn1
, afn2
);
1805 HeapFree( GetProcessHeap(), 0, afn1
);
1806 HeapFree( GetProcessHeap(), 0, afn2
);
1811 /**************************************************************************
1812 * CopyFileA (KERNEL32.36)
1814 BOOL WINAPI
CopyFileA( LPCSTR source
, LPCSTR dest
, BOOL fail_if_exists
)
1817 BY_HANDLE_FILE_INFORMATION info
;
1823 if ((h1
= _lopen( source
, OF_READ
)) == HFILE_ERROR
) return FALSE
;
1824 if (!GetFileInformationByHandle( h1
, &info
))
1829 mode
= (info
.dwFileAttributes
& FILE_ATTRIBUTE_READONLY
) ? 0444 : 0666;
1830 if ((h2
= CreateFileA( dest
, GENERIC_WRITE
, FILE_SHARE_READ
| FILE_SHARE_WRITE
, NULL
,
1831 fail_if_exists
? CREATE_NEW
: CREATE_ALWAYS
,
1832 info
.dwFileAttributes
, h1
)) == HFILE_ERROR
)
1837 while ((count
= _lread( h1
, buffer
, sizeof(buffer
) )) > 0)
1842 INT res
= _lwrite( h2
, p
, count
);
1843 if (res
<= 0) goto done
;
1856 /**************************************************************************
1857 * CopyFileW (KERNEL32.37)
1859 BOOL WINAPI
CopyFileW( LPCWSTR source
, LPCWSTR dest
, BOOL fail_if_exists
)
1861 LPSTR sourceA
= HEAP_strdupWtoA( GetProcessHeap(), 0, source
);
1862 LPSTR destA
= HEAP_strdupWtoA( GetProcessHeap(), 0, dest
);
1863 BOOL ret
= CopyFileA( sourceA
, destA
, fail_if_exists
);
1864 HeapFree( GetProcessHeap(), 0, sourceA
);
1865 HeapFree( GetProcessHeap(), 0, destA
);
1870 /**************************************************************************
1871 * CopyFileExA (KERNEL32.858)
1873 * This implementation ignores most of the extra parameters passed-in into
1874 * the "ex" version of the method and calls the CopyFile method.
1875 * It will have to be fixed eventually.
1877 BOOL WINAPI
CopyFileExA(LPCSTR sourceFilename
,
1878 LPCSTR destFilename
,
1879 LPPROGRESS_ROUTINE progressRoutine
,
1881 LPBOOL cancelFlagPointer
,
1884 BOOL failIfExists
= FALSE
;
1887 * Interpret the only flag that CopyFile can interpret.
1889 if ( (copyFlags
& COPY_FILE_FAIL_IF_EXISTS
) != 0)
1891 failIfExists
= TRUE
;
1894 return CopyFileA(sourceFilename
, destFilename
, failIfExists
);
1897 /**************************************************************************
1898 * CopyFileExW (KERNEL32.859)
1900 BOOL WINAPI
CopyFileExW(LPCWSTR sourceFilename
,
1901 LPCWSTR destFilename
,
1902 LPPROGRESS_ROUTINE progressRoutine
,
1904 LPBOOL cancelFlagPointer
,
1907 LPSTR sourceA
= HEAP_strdupWtoA( GetProcessHeap(), 0, sourceFilename
);
1908 LPSTR destA
= HEAP_strdupWtoA( GetProcessHeap(), 0, destFilename
);
1910 BOOL ret
= CopyFileExA(sourceA
,
1917 HeapFree( GetProcessHeap(), 0, sourceA
);
1918 HeapFree( GetProcessHeap(), 0, destA
);
1924 /***********************************************************************
1925 * SetFileTime (KERNEL32.650)
1927 BOOL WINAPI
SetFileTime( HANDLE hFile
,
1928 const FILETIME
*lpCreationTime
,
1929 const FILETIME
*lpLastAccessTime
,
1930 const FILETIME
*lpLastWriteTime
)
1932 struct set_file_time_request
*req
= get_req_buffer();
1934 req
->handle
= hFile
;
1935 if (lpLastAccessTime
)
1936 req
->access_time
= DOSFS_FileTimeToUnixTime(lpLastAccessTime
, NULL
);
1938 req
->access_time
= 0; /* FIXME */
1939 if (lpLastWriteTime
)
1940 req
->write_time
= DOSFS_FileTimeToUnixTime(lpLastWriteTime
, NULL
);
1942 req
->write_time
= 0; /* FIXME */
1943 return !server_call( REQ_SET_FILE_TIME
);
1947 /**************************************************************************
1948 * LockFile (KERNEL32.511)
1950 BOOL WINAPI
LockFile( HANDLE hFile
, DWORD dwFileOffsetLow
, DWORD dwFileOffsetHigh
,
1951 DWORD nNumberOfBytesToLockLow
, DWORD nNumberOfBytesToLockHigh
)
1953 struct lock_file_request
*req
= get_req_buffer();
1955 req
->handle
= hFile
;
1956 req
->offset_low
= dwFileOffsetLow
;
1957 req
->offset_high
= dwFileOffsetHigh
;
1958 req
->count_low
= nNumberOfBytesToLockLow
;
1959 req
->count_high
= nNumberOfBytesToLockHigh
;
1960 return !server_call( REQ_LOCK_FILE
);
1963 /**************************************************************************
1964 * LockFileEx [KERNEL32.512]
1966 * Locks a byte range within an open file for shared or exclusive access.
1973 * Per Microsoft docs, the third parameter (reserved) must be set to 0.
1975 BOOL WINAPI
LockFileEx( HANDLE hFile
, DWORD flags
, DWORD reserved
,
1976 DWORD nNumberOfBytesToLockLow
, DWORD nNumberOfBytesToLockHigh
,
1977 LPOVERLAPPED pOverlapped
)
1979 FIXME("hFile=%d,flags=%ld,reserved=%ld,lowbytes=%ld,highbytes=%ld,overlapped=%p: stub.\n",
1980 hFile
, flags
, reserved
, nNumberOfBytesToLockLow
, nNumberOfBytesToLockHigh
,
1983 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1986 ERR("reserved == %ld: Supposed to be 0??\n", reserved
);
1987 SetLastError(ERROR_INVALID_PARAMETER
);
1994 /**************************************************************************
1995 * UnlockFile (KERNEL32.703)
1997 BOOL WINAPI
UnlockFile( HANDLE hFile
, DWORD dwFileOffsetLow
, DWORD dwFileOffsetHigh
,
1998 DWORD nNumberOfBytesToUnlockLow
, DWORD nNumberOfBytesToUnlockHigh
)
2000 struct unlock_file_request
*req
= get_req_buffer();
2002 req
->handle
= hFile
;
2003 req
->offset_low
= dwFileOffsetLow
;
2004 req
->offset_high
= dwFileOffsetHigh
;
2005 req
->count_low
= nNumberOfBytesToUnlockLow
;
2006 req
->count_high
= nNumberOfBytesToUnlockHigh
;
2007 return !server_call( REQ_UNLOCK_FILE
);
2011 /**************************************************************************
2012 * UnlockFileEx (KERNEL32.705)
2014 BOOL WINAPI
UnlockFileEx(
2017 DWORD nNumberOfBytesToUnlockLow
,
2018 DWORD nNumberOfBytesToUnlockHigh
,
2019 LPOVERLAPPED lpOverlapped
2022 FIXME("hFile=%d,reserved=%ld,lowbytes=%ld,highbytes=%ld,overlapped=%p: stub.\n",
2023 hFile
, dwReserved
, nNumberOfBytesToUnlockLow
, nNumberOfBytesToUnlockHigh
,
2025 if (dwReserved
== 0)
2026 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
2029 ERR("reserved == %ld: Supposed to be 0??\n", dwReserved
);
2030 SetLastError(ERROR_INVALID_PARAMETER
);
2039 struct DOS_FILE_LOCK
{
2040 struct DOS_FILE_LOCK
* next
;
2044 FILE_OBJECT
* dos_file
;
2045 /* char * unix_name;*/
2048 typedef struct DOS_FILE_LOCK DOS_FILE_LOCK
;
2050 static DOS_FILE_LOCK
*locks
= NULL
;
2051 static void DOS_RemoveFileLocks(FILE_OBJECT
*file
);
2054 /* Locks need to be mirrored because unix file locking is based
2055 * on the pid. Inside of wine there can be multiple WINE processes
2056 * that share the same unix pid.
2057 * Read's and writes should check these locks also - not sure
2058 * how critical that is at this point (FIXME).
2061 static BOOL
DOS_AddLock(FILE_OBJECT
*file
, struct flock
*f
)
2063 DOS_FILE_LOCK
*curr
;
2066 processId
= GetCurrentProcessId();
2068 /* check if lock overlaps a current lock for the same file */
2070 for (curr
= locks
; curr
; curr
= curr
->next
) {
2071 if (strcmp(curr
->unix_name
, file
->unix_name
) == 0) {
2072 if ((f
->l_start
== curr
->base
) && (f
->l_len
== curr
->len
))
2073 return TRUE
;/* region is identic */
2074 if ((f
->l_start
< (curr
->base
+ curr
->len
)) &&
2075 ((f
->l_start
+ f
->l_len
) > curr
->base
)) {
2076 /* region overlaps */
2083 curr
= HeapAlloc( GetProcessHeap(), 0, sizeof(DOS_FILE_LOCK
) );
2084 curr
->processId
= GetCurrentProcessId();
2085 curr
->base
= f
->l_start
;
2086 curr
->len
= f
->l_len
;
2087 /* curr->unix_name = HEAP_strdupA( GetProcessHeap(), 0, file->unix_name);*/
2089 curr
->dos_file
= file
;
2094 static void DOS_RemoveFileLocks(FILE_OBJECT
*file
)
2097 DOS_FILE_LOCK
**curr
;
2100 processId
= GetCurrentProcessId();
2103 if ((*curr
)->dos_file
== file
) {
2105 *curr
= (*curr
)->next
;
2106 /* HeapFree( GetProcessHeap(), 0, rem->unix_name );*/
2107 HeapFree( GetProcessHeap(), 0, rem
);
2110 curr
= &(*curr
)->next
;
2114 static BOOL
DOS_RemoveLock(FILE_OBJECT
*file
, struct flock
*f
)
2117 DOS_FILE_LOCK
**curr
;
2120 processId
= GetCurrentProcessId();
2121 for (curr
= &locks
; *curr
; curr
= &(*curr
)->next
) {
2122 if ((*curr
)->processId
== processId
&&
2123 (*curr
)->dos_file
== file
&&
2124 (*curr
)->base
== f
->l_start
&&
2125 (*curr
)->len
== f
->l_len
) {
2126 /* this is the same lock */
2128 *curr
= (*curr
)->next
;
2129 /* HeapFree( GetProcessHeap(), 0, rem->unix_name );*/
2130 HeapFree( GetProcessHeap(), 0, rem
);
2134 /* no matching lock found */
2139 /**************************************************************************
2140 * LockFile (KERNEL32.511)
2142 BOOL WINAPI
LockFile(
2143 HFILE hFile
,DWORD dwFileOffsetLow
,DWORD dwFileOffsetHigh
,
2144 DWORD nNumberOfBytesToLockLow
,DWORD nNumberOfBytesToLockHigh
)
2149 TRACE("handle %d offsetlow=%ld offsethigh=%ld nbyteslow=%ld nbyteshigh=%ld\n",
2150 hFile
, dwFileOffsetLow
, dwFileOffsetHigh
,
2151 nNumberOfBytesToLockLow
, nNumberOfBytesToLockHigh
);
2153 if (dwFileOffsetHigh
|| nNumberOfBytesToLockHigh
) {
2154 FIXME("Unimplemented bytes > 32bits\n");
2158 f
.l_start
= dwFileOffsetLow
;
2159 f
.l_len
= nNumberOfBytesToLockLow
;
2160 f
.l_whence
= SEEK_SET
;
2164 if (!(file
= FILE_GetFile(hFile
,0,NULL
))) return FALSE
;
2166 /* shadow locks internally */
2167 if (!DOS_AddLock(file
, &f
)) {
2168 SetLastError( ERROR_LOCK_VIOLATION
);
2172 /* FIXME: Unix locking commented out for now, doesn't work with Excel */
2173 #ifdef USE_UNIX_LOCKS
2174 if (fcntl(file
->unix_handle
, F_SETLK
, &f
) == -1) {
2175 if (errno
== EACCES
|| errno
== EAGAIN
) {
2176 SetLastError( ERROR_LOCK_VIOLATION
);
2181 /* remove our internal copy of the lock */
2182 DOS_RemoveLock(file
, &f
);
2190 /**************************************************************************
2191 * UnlockFile (KERNEL32.703)
2193 BOOL WINAPI
UnlockFile(
2194 HFILE hFile
,DWORD dwFileOffsetLow
,DWORD dwFileOffsetHigh
,
2195 DWORD nNumberOfBytesToUnlockLow
,DWORD nNumberOfBytesToUnlockHigh
)
2200 TRACE("handle %d offsetlow=%ld offsethigh=%ld nbyteslow=%ld nbyteshigh=%ld\n",
2201 hFile
, dwFileOffsetLow
, dwFileOffsetHigh
,
2202 nNumberOfBytesToUnlockLow
, nNumberOfBytesToUnlockHigh
);
2204 if (dwFileOffsetHigh
|| nNumberOfBytesToUnlockHigh
) {
2205 WARN("Unimplemented bytes > 32bits\n");
2209 f
.l_start
= dwFileOffsetLow
;
2210 f
.l_len
= nNumberOfBytesToUnlockLow
;
2211 f
.l_whence
= SEEK_SET
;
2215 if (!(file
= FILE_GetFile(hFile
,0,NULL
))) return FALSE
;
2217 DOS_RemoveLock(file
, &f
); /* ok if fails - may be another wine */
2219 /* FIXME: Unix locking commented out for now, doesn't work with Excel */
2220 #ifdef USE_UNIX_LOCKS
2221 if (fcntl(file
->unix_handle
, F_SETLK
, &f
) == -1) {
2230 /**************************************************************************
2231 * GetFileAttributesExA [KERNEL32.874]
2233 BOOL WINAPI
GetFileAttributesExA(
2234 LPCSTR lpFileName
, GET_FILEEX_INFO_LEVELS fInfoLevelId
,
2235 LPVOID lpFileInformation
)
2237 DOS_FULL_NAME full_name
;
2238 BY_HANDLE_FILE_INFORMATION info
;
2240 if (lpFileName
== NULL
) return FALSE
;
2241 if (lpFileInformation
== NULL
) return FALSE
;
2243 if (fInfoLevelId
== GetFileExInfoStandard
) {
2244 LPWIN32_FILE_ATTRIBUTE_DATA lpFad
=
2245 (LPWIN32_FILE_ATTRIBUTE_DATA
) lpFileInformation
;
2246 if (!DOSFS_GetFullName( lpFileName
, TRUE
, &full_name
)) return FALSE
;
2247 if (!FILE_Stat( full_name
.long_name
, &info
)) return FALSE
;
2249 lpFad
->dwFileAttributes
= info
.dwFileAttributes
;
2250 lpFad
->ftCreationTime
= info
.ftCreationTime
;
2251 lpFad
->ftLastAccessTime
= info
.ftLastAccessTime
;
2252 lpFad
->ftLastWriteTime
= info
.ftLastWriteTime
;
2253 lpFad
->nFileSizeHigh
= info
.nFileSizeHigh
;
2254 lpFad
->nFileSizeLow
= info
.nFileSizeLow
;
2257 FIXME("invalid info level %d!\n", fInfoLevelId
);
2265 /**************************************************************************
2266 * GetFileAttributesExW [KERNEL32.875]
2268 BOOL WINAPI
GetFileAttributesExW(
2269 LPCWSTR lpFileName
, GET_FILEEX_INFO_LEVELS fInfoLevelId
,
2270 LPVOID lpFileInformation
)
2272 LPSTR nameA
= HEAP_strdupWtoA( GetProcessHeap(), 0, lpFileName
);
2274 GetFileAttributesExA( nameA
, fInfoLevelId
, lpFileInformation
);
2275 HeapFree( GetProcessHeap(), 0, nameA
);