X-Git-Url: http://git.jankratochvil.net/?p=reactos.git;a=blobdiff_plain;f=lib%2Fkernel32%2Ffile%2Ffile.c;h=7c62d0f05c75e28a9d34b0fd8bcd953895a60f6c;hp=72572f6012c1e48a36eb8fe6232d91b9a2c7f4af;hb=HEAD;hpb=7c0db166f81fbe8c8b913d7f26048e337d383605 diff --git a/lib/kernel32/file/file.c b/lib/kernel32/file/file.c index 72572f6..7c62d0f 100644 --- a/lib/kernel32/file/file.c +++ b/lib/kernel32/file/file.c @@ -25,6 +25,9 @@ WINBOOL bIsFileApiAnsi = TRUE; // set the file api to ansi or oem /* FUNCTIONS ****************************************************************/ +/* + * @implemented + */ VOID STDCALL SetFileApisToOEM(VOID) { @@ -32,6 +35,9 @@ SetFileApisToOEM(VOID) } +/* + * @implemented + */ VOID STDCALL SetFileApisToANSI(VOID) { @@ -39,6 +45,9 @@ SetFileApisToANSI(VOID) } +/* + * @implemented + */ WINBOOL STDCALL AreFileApisANSI(VOID) { @@ -46,6 +55,9 @@ AreFileApisANSI(VOID) } +/* + * @implemented + */ HFILE STDCALL OpenFile(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, @@ -148,6 +160,9 @@ OpenFile(LPCSTR lpFileName, } +/* + * @implemented + */ WINBOOL STDCALL FlushFileBuffers(HANDLE hFile) { @@ -170,6 +185,9 @@ FlushFileBuffers(HANDLE hFile) } +/* + * @implemented + */ DWORD STDCALL SetFilePointer(HANDLE hFile, LONG lDistanceToMove, @@ -242,6 +260,9 @@ SetFilePointer(HANDLE hFile, } +/* + * @implemented + */ DWORD STDCALL GetFileType(HANDLE hFile) { @@ -314,6 +335,9 @@ GetFileType(HANDLE hFile) } +/* + * @implemented + */ DWORD STDCALL GetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh) @@ -346,6 +370,9 @@ GetFileSize(HANDLE hFile, } +/* + * @implemented + */ DWORD STDCALL GetCompressedFileSizeA(LPCSTR lpFileName, LPDWORD lpFileSizeHigh) @@ -376,6 +403,9 @@ GetCompressedFileSizeA(LPCSTR lpFileName, } +/* + * @implemented + */ DWORD STDCALL GetCompressedFileSizeW(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh) @@ -413,6 +443,9 @@ GetCompressedFileSizeW(LPCWSTR lpFileName, } +/* + * @implemented + */ WINBOOL STDCALL GetFileInformationByHandle(HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation) @@ -492,45 +525,30 @@ GetFileInformationByHandle(HANDLE hFile, } -DWORD STDCALL -GetFileAttributesA(LPCSTR lpFileName) -{ - UNICODE_STRING FileNameU; - ANSI_STRING FileName; - WINBOOL Result; - - RtlInitAnsiString (&FileName, - (LPSTR)lpFileName); - - /* convert ansi (or oem) string to unicode */ - if (bIsFileApiAnsi) - RtlAnsiStringToUnicodeString (&FileNameU, - &FileName, - TRUE); - else - RtlOemStringToUnicodeString (&FileNameU, - &FileName, - TRUE); - - Result = GetFileAttributesW (FileNameU.Buffer); - - RtlFreeUnicodeString (&FileNameU); - - return Result; -} - - -DWORD STDCALL -GetFileAttributesW(LPCWSTR lpFileName) +/* + * @implemented + */ +BOOL STDCALL +GetFileAttributesExW(LPCWSTR lpFileName, + GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation) { - FILE_BASIC_INFORMATION FileInformation; + FILE_NETWORK_OPEN_INFORMATION FileInformation; OBJECT_ATTRIBUTES ObjectAttributes; IO_STATUS_BLOCK IoStatusBlock; UNICODE_STRING FileName; HANDLE FileHandle; NTSTATUS Status; + WIN32_FILE_ATTRIBUTE_DATA* FileAttributeData; - DPRINT ("GetFileAttributeW(%S) called\n", lpFileName); + DPRINT ("GetFileAttributesExW(%S) called\n", lpFileName); + + + if (fInfoLevelId != GetFileExInfoStandard || lpFileInformation == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } /* Validate and translate the filename */ if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFileName, @@ -540,9 +558,8 @@ GetFileAttributesW(LPCWSTR lpFileName) { DPRINT ("Invalid path\n"); SetLastError (ERROR_BAD_PATHNAME); - return 0xFFFFFFFF; + return FALSE; } - DPRINT ("FileName: \'%wZ\'\n", &FileName); /* build the object attributes */ InitializeObjectAttributes (&ObjectAttributes, @@ -563,26 +580,117 @@ GetFileAttributesW(LPCWSTR lpFileName) { DPRINT ("NtOpenFile() failed (Status %lx)\n", Status); SetLastErrorByStatus (Status); - return 0xFFFFFFFF; + return FALSE; } /* Get file attributes */ Status = NtQueryInformationFile (FileHandle, &IoStatusBlock, &FileInformation, - sizeof(FILE_BASIC_INFORMATION), - FileBasicInformation); + sizeof(FILE_NETWORK_OPEN_INFORMATION), + FileNetworkOpenInformation); NtClose (FileHandle); + if (!NT_SUCCESS (Status)) { DPRINT ("NtQueryInformationFile() failed (Status %lx)\n", Status); SetLastErrorByStatus (Status); - return 0xFFFFFFFF; + return FALSE; } - return (DWORD)FileInformation.FileAttributes; + FileAttributeData = (WIN32_FILE_ATTRIBUTE_DATA*)lpFileInformation; + FileAttributeData->dwFileAttributes = FileInformation.FileAttributes; + FileAttributeData->ftCreationTime.dwLowDateTime = FileInformation.CreationTime.u.LowPart; + FileAttributeData->ftCreationTime.dwHighDateTime = FileInformation.CreationTime.u.HighPart; + FileAttributeData->ftLastAccessTime.dwLowDateTime = FileInformation.LastAccessTime.u.LowPart; + FileAttributeData->ftLastAccessTime.dwHighDateTime = FileInformation.LastAccessTime.u.HighPart; + FileAttributeData->ftLastWriteTime.dwLowDateTime = FileInformation.LastWriteTime.u.LowPart; + FileAttributeData->ftLastWriteTime.dwHighDateTime = FileInformation.LastWriteTime.u.HighPart; + FileAttributeData->nFileSizeLow = FileInformation.EndOfFile.u.LowPart; + FileAttributeData->nFileSizeHigh = FileInformation.EndOfFile.u.HighPart; + + return TRUE; } +/* + * @implemented + */ +BOOL STDCALL +GetFileAttributesExA(LPCSTR lpFileName, + GET_FILEEX_INFO_LEVELS fInfoLevelId, + LPVOID lpFileInformation) +{ + UNICODE_STRING FileNameU; + ANSI_STRING FileName; + BOOL Result; + RtlInitAnsiString (&FileName, + (LPSTR)lpFileName); + + /* convert ansi (or oem) string to unicode */ + if (bIsFileApiAnsi) + RtlAnsiStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + else + RtlOemStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + + Result = GetFileAttributesExW(FileNameU.Buffer, fInfoLevelId, lpFileInformation); + + RtlFreeUnicodeString (&FileNameU); + + return Result; +} + + +/* + * @implemented + */ +DWORD STDCALL +GetFileAttributesA(LPCSTR lpFileName) +{ + WIN32_FILE_ATTRIBUTE_DATA FileAttributeData; + UNICODE_STRING FileNameU; + ANSI_STRING FileName; + BOOL Result; + + RtlInitAnsiString (&FileName, + (LPSTR)lpFileName); + + /* convert ansi (or oem) string to unicode */ + if (bIsFileApiAnsi) + RtlAnsiStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + else + RtlOemStringToUnicodeString (&FileNameU, + &FileName, + TRUE); + + Result = GetFileAttributesExW(FileNameU.Buffer, GetFileExInfoStandard, &FileAttributeData); + + RtlFreeUnicodeString (&FileNameU); + + return Result ? FileAttributeData.dwFileAttributes : 0xffffffff; +} + + +/* + * @implemented + */ +DWORD STDCALL +GetFileAttributesW(LPCWSTR lpFileName) +{ + WIN32_FILE_ATTRIBUTE_DATA FileAttributeData; + BOOL Result; + + DPRINT ("GetFileAttributeW(%S) called\n", lpFileName); + + Result = GetFileAttributesExW(lpFileName, GetFileExInfoStandard, &FileAttributeData); + + return Result ? FileAttributeData.dwFileAttributes : 0xffffffff; +} WINBOOL STDCALL SetFileAttributesA(LPCSTR lpFileName, @@ -614,6 +722,9 @@ SetFileAttributesA(LPCSTR lpFileName, } +/* + * @implemented + */ WINBOOL STDCALL SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes) @@ -692,6 +803,9 @@ SetFileAttributesW(LPCWSTR lpFileName, } +/* + * @implemented + */ UINT STDCALL GetTempFileNameA(LPCSTR lpPathName, LPCSTR lpPrefixString, @@ -737,6 +851,9 @@ GetTempFileNameA(LPCSTR lpPathName, } +/* + * @implemented + */ UINT STDCALL GetTempFileNameW(LPCWSTR lpPathName, LPCWSTR lpPrefixString, @@ -746,7 +863,7 @@ GetTempFileNameW(LPCWSTR lpPathName, HANDLE hFile; UINT unique = uUnique; UINT len; - const WCHAR *format = L"%.*S\\~%.3S%4.4x.TMP"; + const WCHAR *format = L"%.*s\\~%.3s%4.4x.TMP"; DPRINT("GetTempFileNameW(lpPathName %S, lpPrefixString %.*S, " "uUnique %x, lpTempFileName %x)\n", lpPathName, 4, @@ -782,6 +899,9 @@ GetTempFileNameW(LPCWSTR lpPathName, } +/* + * @implemented + */ WINBOOL STDCALL GetFileTime(HANDLE hFile, LPFILETIME lpCreationTime, @@ -814,6 +934,9 @@ GetFileTime(HANDLE hFile, } +/* + * @implemented + */ WINBOOL STDCALL SetFileTime(HANDLE hFile, CONST FILETIME *lpCreationTime, @@ -860,8 +983,10 @@ SetFileTime(HANDLE hFile, /* -The caller must have opened the file with the DesiredAccess FILE_WRITE_DATA flag set. -*/ + * The caller must have opened the file with the DesiredAccess FILE_WRITE_DATA flag set. + * + * @implemented + */ WINBOOL STDCALL SetEndOfFile(HANDLE hFile) {