- Implemented GetFileAttributesExA/W.

svn path=/trunk/; revision=4877
This commit is contained in:
Hartmut Birr 2003-06-09 19:58:21 +00:00
parent 52b40cdd07
commit e9f3a8740c
6 changed files with 122 additions and 69 deletions

View file

@ -606,6 +606,14 @@ GetFileAttributesA(
LPCSTR lpFileName LPCSTR lpFileName
); );
BOOL
STDCALL
GetFileAttributesExA(
LPCSTR lpFileName,
GET_FILEEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFileInformation
);
DWORD DWORD
STDCALL STDCALL
GetCompressedFileSizeA( GetCompressedFileSizeA(

View file

@ -347,6 +347,7 @@ typedef PPROGRESS_ROUTINE LPPROGRESS_ROUTINE;
#define CreateFile CreateFileW #define CreateFile CreateFileW
#define SetFileAttributes SetFileAttributesW #define SetFileAttributes SetFileAttributesW
#define GetFileAttributes GetFileAttributesW #define GetFileAttributes GetFileAttributesW
#define GetFileAttributesEx GetFileAttributesExW
#define GetCompressedFileSize GetCompressedFileSizeW #define GetCompressedFileSize GetCompressedFileSizeW
#define DeleteFile DeleteFileW #define DeleteFile DeleteFileW
#define FindFirstFileEx FindFirstFileExW #define FindFirstFileEx FindFirstFileExW
@ -753,6 +754,7 @@ typedef PPROGRESS_ROUTINE LPPROGRESS_ROUTINE;
#define CreateFile CreateFileA #define CreateFile CreateFileA
#define SetFileAttributes SetFileAttributesA #define SetFileAttributes SetFileAttributesA
#define GetFileAttributes GetFileAttributesA #define GetFileAttributes GetFileAttributesA
#define GetFileAttributesEx GetFileAttributesExA
#define GetCompressedFileSize GetCompressedFileSizeA #define GetCompressedFileSize GetCompressedFileSizeA
#define DeleteFile DeleteFileA #define DeleteFile DeleteFileA
#define FindFirstFileEx FindFirstFileExA #define FindFirstFileEx FindFirstFileExA

View file

@ -607,6 +607,14 @@ GetFileAttributesW(
LPCWSTR lpFileName LPCWSTR lpFileName
); );
BOOL
STDCALL
GetFileAttributesExW(
LPCWSTR lpFileName,
GET_FILEEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFileInformation
);
DWORD DWORD
STDCALL STDCALL
GetCompressedFileSizeW( GetCompressedFileSizeW(

View file

@ -1,4 +1,4 @@
/* $Id: file.c,v 1.43 2003/03/23 04:01:16 ekohl Exp $ /* $Id: file.c,v 1.44 2003/06/09 19:58:21 hbirr Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -491,46 +491,27 @@ GetFileInformationByHandle(HANDLE hFile,
return TRUE; return TRUE;
} }
BOOL STDCALL
DWORD STDCALL GetFileAttributesExW(LPCWSTR lpFileName,
GetFileAttributesA(LPCSTR lpFileName) GET_FILEEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFileInformation)
{ {
UNICODE_STRING FileNameU; FILE_NETWORK_OPEN_INFORMATION FileInformation;
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)
{
FILE_BASIC_INFORMATION FileInformation;
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
UNICODE_STRING FileName; UNICODE_STRING FileName;
HANDLE FileHandle; HANDLE FileHandle;
NTSTATUS Status; 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 */ /* Validate and translate the filename */
if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFileName, if (!RtlDosPathNameToNtPathName_U ((LPWSTR)lpFileName,
@ -540,9 +521,8 @@ GetFileAttributesW(LPCWSTR lpFileName)
{ {
DPRINT ("Invalid path\n"); DPRINT ("Invalid path\n");
SetLastError (ERROR_BAD_PATHNAME); SetLastError (ERROR_BAD_PATHNAME);
return 0xFFFFFFFF; return FALSE;
} }
DPRINT ("FileName: \'%wZ\'\n", &FileName);
/* build the object attributes */ /* build the object attributes */
InitializeObjectAttributes (&ObjectAttributes, InitializeObjectAttributes (&ObjectAttributes,
@ -563,26 +543,106 @@ GetFileAttributesW(LPCWSTR lpFileName)
{ {
DPRINT ("NtOpenFile() failed (Status %lx)\n", Status); DPRINT ("NtOpenFile() failed (Status %lx)\n", Status);
SetLastErrorByStatus (Status); SetLastErrorByStatus (Status);
return 0xFFFFFFFF; return FALSE;
} }
/* Get file attributes */ /* Get file attributes */
Status = NtQueryInformationFile (FileHandle, Status = NtQueryInformationFile (FileHandle,
&IoStatusBlock, &IoStatusBlock,
&FileInformation, &FileInformation,
sizeof(FILE_BASIC_INFORMATION), sizeof(FILE_NETWORK_OPEN_INFORMATION),
FileBasicInformation); FileNetworkOpenInformation);
NtClose (FileHandle); NtClose (FileHandle);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT ("NtQueryInformationFile() failed (Status %lx)\n", Status); DPRINT ("NtQueryInformationFile() failed (Status %lx)\n", Status);
SetLastErrorByStatus (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;
} }
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;
}
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;
}
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 WINBOOL STDCALL
SetFileAttributesA(LPCSTR lpFileName, SetFileAttributesA(LPCSTR lpFileName,

View file

@ -265,8 +265,8 @@ GetExitCodeProcess@8
GetExitCodeThread@8 GetExitCodeThread@8
GetFileAttributesA@4 GetFileAttributesA@4
GetFileAttributesW@4 GetFileAttributesW@4
GetFileAttributesExA GetFileAttributesExA@12
GetFileAttributesExW GetFileAttributesExW@12
GetFileInformationByHandle@8 GetFileInformationByHandle@8
GetFileSize@8 GetFileSize@8
GetFileTime@16 GetFileTime@16

View file

@ -1,4 +1,4 @@
/* $Id: stubs.c,v 1.50 2003/06/08 20:59:30 ekohl Exp $ /* $Id: stubs.c,v 1.51 2003/06/09 19:58:21 hbirr Exp $
* *
* KERNEL32.DLL stubs (unimplemented functions) * KERNEL32.DLL stubs (unimplemented functions)
* Remove from this file, if you implement them. * Remove from this file, if you implement them.
@ -945,29 +945,4 @@ VirtualBufferExceptionHandler (
} }
BOOL
STDCALL
GetFileAttributesExA(
LPCSTR lpFileName,
GET_FILEEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFileInformation
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
BOOL
STDCALL
GetFileAttributesExW(
LPCWSTR lpFileName,
GET_FILEEX_INFO_LEVELS fInfoLevelId,
LPVOID lpFileInformation
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
/* EOF */ /* EOF */