ReactOS  0.4.12-dev-914-g71f84a3
fileinfo.c File Reference
#include <k32.h>
#include <debug.h>
Include dependency graph for fileinfo.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 DEBUG_CHANNEL (kernel32file)
 
PWCHAR FilenameA2W (LPCSTR NameA, BOOL alloc)
 
DWORD FilenameU2A_FitOrFail (LPSTR DestA, INT destLen, PUNICODE_STRING SourceU)
 
DWORD FilenameW2A_FitOrFail (LPSTR DestA, INT destLen, LPCWSTR SourceW, INT sourceLen)
 
DWORD FilenameA2W_N (LPWSTR dest, INT destlen, LPCSTR src, INT srclen)
 
DWORD FilenameW2A_N (LPSTR dest, INT destlen, LPCWSTR src, INT srclen)
 
BOOL WINAPI FlushFileBuffers (IN HANDLE hFile)
 
DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer (HANDLE hFile, LONG lDistanceToMove, PLONG lpDistanceToMoveHigh, DWORD dwMoveMethod)
 
BOOL WINAPI SetFilePointerEx (HANDLE hFile, LARGE_INTEGER liDistanceToMove, PLARGE_INTEGER lpNewFilePointer, DWORD dwMoveMethod)
 
DWORD WINAPI GetFileType (HANDLE hFile)
 
DWORD WINAPI GetFileSize (HANDLE hFile, LPDWORD lpFileSizeHigh)
 
BOOL WINAPI GetFileSizeEx (HANDLE hFile, PLARGE_INTEGER lpFileSize)
 
DWORD WINAPI GetCompressedFileSizeA (LPCSTR lpFileName, LPDWORD lpFileSizeHigh)
 
DWORD WINAPI GetCompressedFileSizeW (LPCWSTR lpFileName, LPDWORD lpFileSizeHigh)
 
BOOL WINAPI GetFileInformationByHandle (HANDLE hFile, LPBY_HANDLE_FILE_INFORMATION lpFileInformation)
 
BOOL WINAPI GetFileAttributesExW (LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
 
BOOL WINAPI GetFileAttributesExA (LPCSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
 
DWORD WINAPI GetFileAttributesA (LPCSTR lpFileName)
 
DWORD WINAPI GetFileAttributesW (LPCWSTR lpFileName)
 
BOOL WINAPI GetFileAttributesByHandle (IN HANDLE hFile, OUT LPDWORD dwFileAttributes, IN DWORD dwFlags)
 
BOOL WINAPI SetFileAttributesByHandle (IN HANDLE hFile, IN DWORD dwFileAttributes, IN DWORD dwFlags)
 
BOOL WINAPI SetFileAttributesA (LPCSTR lpFileName, DWORD dwFileAttributes)
 
BOOL WINAPI SetFileAttributesW (LPCWSTR lpFileName, DWORD dwFileAttributes)
 
BOOL WINAPI GetFileTime (IN HANDLE hFile, OUT LPFILETIME lpCreationTime OPTIONAL, OUT LPFILETIME lpLastAccessTime OPTIONAL, OUT LPFILETIME lpLastWriteTime OPTIONAL)
 
BOOL WINAPI SetFileTime (IN HANDLE hFile, CONST FILETIME *lpCreationTime OPTIONAL, CONST FILETIME *lpLastAccessTime OPTIONAL, CONST FILETIME *lpLastWriteTime OPTIONAL)
 
BOOL WINAPI SetEndOfFile (HANDLE hFile)
 
BOOL WINAPI SetFileValidData (HANDLE hFile, LONGLONG ValidDataLength)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file fileinfo.c.

Function Documentation

◆ DEBUG_CHANNEL()

DEBUG_CHANNEL ( kernel32file  )

◆ FilenameA2W()

PWCHAR FilenameA2W ( LPCSTR  NameA,
BOOL  alloc 
)

Definition at line 22 of file fileinfo.c.

23 {
26  PUNICODE_STRING pstrW;
28 
29  //ASSERT(NtCurrentTeb()->StaticUnicodeString.Buffer == NtCurrentTeb()->StaticUnicodeBuffer);
30  ASSERT(NtCurrentTeb()->StaticUnicodeString.MaximumLength == sizeof(NtCurrentTeb()->StaticUnicodeBuffer));
31 
32  RtlInitAnsiString(&str, NameA);
33  pstrW = alloc ? &strW : &NtCurrentTeb()->StaticUnicodeString;
34 
35  if (bIsFileApiAnsi)
37  else
39 
40  if (NT_SUCCESS(Status))
41  return pstrW->Buffer;
42 
45  else
47 
48  return NULL;
49 }
BOOL bIsFileApiAnsi
Definition: utils.c:25
LONG NTSTATUS
Definition: precomp.h:26
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
WCHAR strW[12]
Definition: clipboard.c:2029
const WCHAR * str
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSYSAPI NTSTATUS NTAPI RtlOemStringToUnicodeString(PUNICODE_STRING DestinationString, PCOEM_STRING SourceString, BOOLEAN AllocateDestinationString)
Status
Definition: gdiplustypes.h:24
FORCEINLINE struct _TEB * NtCurrentTeb(VOID)
Definition: psfuncs.h:420
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:61
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
#define alloc
Definition: rosglue.h:13
#define ERROR_FILENAME_EXCED_RANGE
Definition: winerror.h:263

Referenced by CreateFileA(), GetCompressedFileSizeA(), GetFileAttributesA(), GetFileAttributesExA(), SetFileAttributesA(), and SetFileShortNameA().

◆ FilenameA2W_N()

DWORD FilenameA2W_N ( LPWSTR  dest,
INT  destlen,
LPCSTR  src,
INT  srclen 
)

Definition at line 125 of file fileinfo.c.

131 {
132  DWORD ret;
133 
134  if (srclen < 0) srclen = strlen( src ) + 1;
135 
136  if (bIsFileApiAnsi)
137  RtlMultiByteToUnicodeN( dest, destlen* sizeof(WCHAR), &ret, (LPSTR)src, srclen );
138  else
139  RtlOemToUnicodeN( dest, destlen* sizeof(WCHAR), &ret, (LPSTR)src, srclen );
140 
141  if (ret) dest[(ret/sizeof(WCHAR))-1]=0;
142 
143  return ret/sizeof(WCHAR);
144 }
BOOL bIsFileApiAnsi
Definition: utils.c:25
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
NTSYSAPI NTSTATUS WINAPI RtlMultiByteToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
NTSYSAPI NTSTATUS WINAPI RtlOemToUnicodeN(LPWSTR, DWORD, LPDWORD, LPCSTR, DWORD)
char * LPSTR
Definition: xmlstorage.h:182
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:51
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135

◆ FilenameU2A_FitOrFail()

DWORD FilenameU2A_FitOrFail ( LPSTR  DestA,
INT  destLen,
PUNICODE_STRING  SourceU 
)

Definition at line 60 of file fileinfo.c.

65 {
66  DWORD ret;
67 
68  /* destLen should never exceed MAX_PATH */
69  if (destLen > MAX_PATH) destLen = MAX_PATH;
70 
72  /* ret incl. nullchar */
73 
74  if (DestA && (INT)ret <= destLen)
75  {
77 
78  str.Buffer = DestA;
79  str.MaximumLength = (USHORT)destLen;
80 
81 
82  if (bIsFileApiAnsi)
84  else
86 
87  ret = str.Length; /* SUCCESS: length without terminating 0 */
88  }
89 
90  return ret;
91 }
NTSYSAPI DWORD WINAPI RtlUnicodeStringToAnsiSize(const UNICODE_STRING *)
BOOL bIsFileApiAnsi
Definition: utils.c:25
NTSYSAPI DWORD WINAPI RtlUnicodeStringToOemSize(const UNICODE_STRING *)
int32_t INT
Definition: typedefs.h:56
const WCHAR * str
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToAnsiString(PANSI_STRING DestinationString, PUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToOemString(POEM_STRING DestinationString, PCUNICODE_STRING SourceString, BOOLEAN AllocateDestinationString)
unsigned short USHORT
Definition: pedump.c:61

Referenced by FilenameW2A_FitOrFail().

◆ FilenameW2A_FitOrFail()

DWORD FilenameW2A_FitOrFail ( LPSTR  DestA,
INT  destLen,
LPCWSTR  SourceW,
INT  sourceLen 
)

Definition at line 102 of file fileinfo.c.

108 {
110 
111  if (sourceLen < 0) sourceLen = wcslen(SourceW) + 1;
112 
113  strW.Buffer = (PWCHAR)SourceW;
114  strW.MaximumLength = sourceLen * sizeof(WCHAR);
115  strW.Length = strW.MaximumLength - sizeof(WCHAR);
116 
117  return FilenameU2A_FitOrFail(DestA, destLen, &strW);
118 }
uint16_t * PWCHAR
Definition: typedefs.h:54
DWORD FilenameU2A_FitOrFail(LPSTR DestA, INT destLen, PUNICODE_STRING SourceU)
Definition: fileinfo.c:60
WCHAR strW[12]
Definition: clipboard.c:2029
__wchar_t WCHAR
Definition: xmlstorage.h:180
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by GetTempPathA().

◆ FilenameW2A_N()

DWORD FilenameW2A_N ( LPSTR  dest,
INT  destlen,
LPCWSTR  src,
INT  srclen 
)

Definition at line 150 of file fileinfo.c.

156 {
157  DWORD ret;
158 
159  if (srclen < 0) srclen = wcslen( src ) + 1;
160 
161  if (bIsFileApiAnsi)
162  RtlUnicodeToMultiByteN( dest, destlen, &ret, (LPWSTR) src, srclen * sizeof(WCHAR));
163  else
164  RtlUnicodeToOemN( dest, destlen, &ret, (LPWSTR) src, srclen * sizeof(WCHAR) );
165 
166  if (ret) dest[ret-1]=0;
167 
168  return ret;
169 }
BOOL bIsFileApiAnsi
Definition: utils.c:25
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToOemN(PCHAR OemString, ULONG OemSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD LPDWORD LPCSTR DWORD srclen
Definition: directory.c:51
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
NTSYSAPI NTSTATUS NTAPI RtlUnicodeToMultiByteN(PCHAR MbString, ULONG MbSize, PULONG ResultSize, PCWCH UnicodeString, ULONG UnicodeSize)
GLenum src
Definition: glext.h:6340
static char * dest
Definition: rtl.c:135
WCHAR * LPWSTR
Definition: xmlstorage.h:184
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

◆ FlushFileBuffers()

BOOL WINAPI FlushFileBuffers ( IN HANDLE  hFile)

Definition at line 175 of file fileinfo.c.

176 {
179 
181 
182  if (IsConsoleHandle(hFile))
183  {
185  }
186 
188  &IoStatusBlock);
189  if (!NT_SUCCESS(Status))
190  {
192  return FALSE;
193  }
194  return TRUE;
195 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
Definition: console.c:169
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
NTSTATUS NTAPI NtFlushBuffersFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: iofunc.c:1377
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IsConsoleHandle(h)
Definition: console.h:14
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

Referenced by _commit(), _test_flush_sync(), BasepMoveFileCopyProgress(), ConStreamSetOSHandle(), DosFlushFileBuffers(), flush_proc(), InstanceThread(), local_server_thread(), pipe_thread(), rpcrt4_conn_np_close(), CJournaledTestList::SerializeIntoJournal(), serverThreadMain1(), serverThreadMain2(), serverThreadMain3(), serverThreadMain4(), serverThreadMain5(), test_FlushFileBuffers(), test_get_digest_stream(), test_sip_create_indirect_data(), test_waittxempty(), UninitLogging(), UnmountDisk(), CJournaledTestList::UpdateJournal(), and CJournaledTestList::WriteInitialJournalFile().

◆ GetCompressedFileSizeA()

DWORD WINAPI GetCompressedFileSizeA ( LPCSTR  lpFileName,
LPDWORD  lpFileSizeHigh 
)

Definition at line 547 of file fileinfo.c.

549 {
550  PWCHAR FileNameW;
551 
552  if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
553  return INVALID_FILE_SIZE;
554 
555  return GetCompressedFileSizeW(FileNameW, lpFileSizeHigh);
556 }
#define INVALID_FILE_SIZE
Definition: winbase.h:529
uint16_t * PWCHAR
Definition: typedefs.h:54
PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc)
Definition: fileinfo.c:22
DWORD WINAPI GetCompressedFileSizeW(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:563
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

◆ GetCompressedFileSizeW()

DWORD WINAPI GetCompressedFileSizeW ( LPCWSTR  lpFileName,
LPDWORD  lpFileSizeHigh 
)

Definition at line 563 of file fileinfo.c.

565 {
566  FILE_COMPRESSION_INFORMATION FileCompression;
567  NTSTATUS errCode;
569  HANDLE hFile;
570 
572  GENERIC_READ,
574  NULL,
577  NULL);
578 
580  return INVALID_FILE_SIZE;
581 
582  errCode = NtQueryInformationFile(hFile,
583  &IoStatusBlock,
584  &FileCompression,
587 
589 
590  if (!NT_SUCCESS(errCode))
591  {
592  BaseSetLastNTError(errCode);
593  return INVALID_FILE_SIZE;
594  }
595 
596  if(lpFileSizeHigh)
597  *lpFileSizeHigh = FileCompression.CompressedFileSize.u.HighPart;
598 
600  return FileCompression.CompressedFileSize.u.LowPart;
601 }
#define CloseHandle
Definition: compat.h:398
LONG NTSTATUS
Definition: precomp.h:26
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
LARGE_INTEGER CompressedFileSize
Definition: iotypes.h:5492
#define INVALID_FILE_SIZE
Definition: winbase.h:529
#define NO_ERROR
Definition: dderror.h:5
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define OPEN_EXISTING
Definition: compat.h:426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define GENERIC_READ
Definition: compat.h:124
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define CreateFileW
Definition: compat.h:400
struct _LARGE_INTEGER::@2192 u
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

Referenced by GetCompressedFileSizeA().

◆ GetFileAttributesA()

DWORD WINAPI GetFileAttributesA ( LPCSTR  lpFileName)

Definition at line 786 of file fileinfo.c.

787 {
788  PWSTR FileNameW;
789 
790  if (!lpFileName || !(FileNameW = FilenameA2W(lpFileName, FALSE)))
792 
793  return GetFileAttributesW(FileNameW);
794 }
uint16_t * PWSTR
Definition: typedefs.h:54
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc)
Definition: fileinfo.c:22
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

Referenced by _access(), _chmod(), _mktemp(), check_exists(), check_ini_file_attr(), create_backup(), create_file(), delete_file(), dir_exists(), does_folder_or_file_exist(), DosChangeDirectory(), DosCreateFile(), DosCreateFileEx(), DosInt21h(), DosOpenFile(), enum_gac_assembly_dirs(), Extract(), ExtractFilesA(), fci_open(), fdi_notify_extract(), file_exists(), get_open_info(), init_test(), MACRO_FileExist(), MMIO_Open(), OpenFile(), PathFileExistsA(), PathFileExistsAndAttributesA(), PathIsDirectoryA(), PathIsSystemFolderA(), PathUnmakeSystemFolderA(), register_service(), search_absolute_directory(), SHAddToRecentDocs(), shell_execute_(), shell_execute_ex_(), START_TEST(), test__creat(), test__lcreat(), test_AddDelBackupEntry(), test_autocreation(), test_backup(), test_catalog_properties(), test_clear(), test_context(), test_CopyFileEx(), test_create_catalog_file(), test_CreateScalableFontResource(), test_CryptCATAdminAddRemoveCatalog(), test_date_format(), test_driver_install(), test_ExitCode(), test_file_disposition_information(), test_FileSecurity(), test_find_file(), test_FindFirstChangeNotification(), test_get_file_info(), test_GetDisplayName(), test_getfile(), test_GetFileInformationByHandleEx(), test_info_size(), test_InstallAssembly(), test_keep_attributes(), test_LocalizedNames(), test_LZOpenFileA(), test_msidatabase(), test_openbackup(), test_OpenFile(), test_OpenFileById(), test_parms_syntax(), test_profile_items(), test_QueryAssemblyInfo(), test_relative_path(), test_setpropertyfolder(), test_settargetpath(), test_SHGetFolderPathAndSubDirA(), test_summary_binary(), test_WritePrivateProfileString(), tmpnam(), VerInstallFileA(), and VfdInstallDriver().

◆ GetFileAttributesByHandle()

BOOL WINAPI GetFileAttributesByHandle ( IN HANDLE  hFile,
OUT LPDWORD  dwFileAttributes,
IN DWORD  dwFlags 
)

Definition at line 844 of file fileinfo.c.

847 {
848  FILE_BASIC_INFORMATION FileBasic;
851 
853 
854  if (IsConsoleHandle(hFile))
855  {
857  return FALSE;
858  }
859 
861  &IoStatusBlock,
862  &FileBasic,
863  sizeof(FileBasic),
865  if (NT_SUCCESS(Status))
866  {
867  *dwFileAttributes = FileBasic.FileAttributes;
868  return TRUE;
869  }
870 
872  return FALSE;
873 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define IsConsoleHandle(h)
Definition: console.h:14
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
DWORD dwFileAttributes

◆ GetFileAttributesExA()

BOOL WINAPI GetFileAttributesExA ( LPCSTR  lpFileName,
GET_FILEEX_INFO_LEVELS  fInfoLevelId,
LPVOID  lpFileInformation 
)

Definition at line 769 of file fileinfo.c.

772 {
773  PWCHAR FileNameW;
774 
775  if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
776  return FALSE;
777 
778  return GetFileAttributesExW(FileNameW, fInfoLevelId, lpFileInformation);
779 }
uint16_t * PWCHAR
Definition: typedefs.h:54
PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc)
Definition: fileinfo.c:22
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:702
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

◆ GetFileAttributesExW()

BOOL WINAPI GetFileAttributesExW ( LPCWSTR  lpFileName,
GET_FILEEX_INFO_LEVELS  fInfoLevelId,
LPVOID  lpFileInformation 
)

Definition at line 702 of file fileinfo.c.

705 {
710  WIN32_FILE_ATTRIBUTE_DATA* FileAttributeData;
711 
712  TRACE("GetFileAttributesExW(%S) called\n", lpFileName);
713 
714 
715  if (fInfoLevelId != GetFileExInfoStandard || lpFileInformation == NULL)
716  {
718  return FALSE;
719  }
720 
721  /* Validate and translate the filename */
723  &FileName,
724  NULL,
725  NULL))
726  {
727  WARN ("Invalid path '%S'\n", lpFileName);
729  return FALSE;
730  }
731 
732  /* build the object attributes */
734  &FileName,
736  NULL,
737  NULL);
738 
739  /* Get file attributes */
741  &FileInformation);
742 
744  if (!NT_SUCCESS (Status))
745  {
746  WARN ("NtQueryFullAttributesFile() failed (Status %lx)\n", Status);
748  return FALSE;
749  }
750 
751  FileAttributeData = (WIN32_FILE_ATTRIBUTE_DATA*)lpFileInformation;
752  FileAttributeData->dwFileAttributes = FileInformation.FileAttributes;
753  FileAttributeData->ftCreationTime.dwLowDateTime = FileInformation.CreationTime.u.LowPart;
754  FileAttributeData->ftCreationTime.dwHighDateTime = FileInformation.CreationTime.u.HighPart;
755  FileAttributeData->ftLastAccessTime.dwLowDateTime = FileInformation.LastAccessTime.u.LowPart;
756  FileAttributeData->ftLastAccessTime.dwHighDateTime = FileInformation.LastAccessTime.u.HighPart;
757  FileAttributeData->ftLastWriteTime.dwLowDateTime = FileInformation.LastWriteTime.u.LowPart;
758  FileAttributeData->ftLastWriteTime.dwHighDateTime = FileInformation.LastWriteTime.u.HighPart;
759  FileAttributeData->nFileSizeLow = FileInformation.EndOfFile.u.LowPart;
760  FileAttributeData->nFileSizeHigh = FileInformation.EndOfFile.u.HighPart;
761 
762  return TRUE;
763 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtQueryFullAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation)
Definition: file.c:3989
#define WARN(fmt,...)
Definition: debug.h:111
LONG NTSTATUS
Definition: precomp.h:26
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
DWORD dwHighDateTime
Definition: mapidefs.h:66
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define SetLastError(x)
Definition: compat.h:409
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
Status
Definition: gdiplustypes.h:24
struct _FileName FileName
Definition: fatprocs.h:884
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233
DWORD dwLowDateTime
Definition: mapidefs.h:65
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

Referenced by file_get_DateLastModified(), FileMonikerImpl_GetTimeOfLastChange(), fill_w32fdata_shell(), GetFileAttributesExA(), CFileDefExt::InitFileAttr(), InitPropertiesDlg(), test_GetFileAttributesExW(), urlcache_delete_file(), and urlcache_entry_commit().

◆ GetFileAttributesW()

DWORD WINAPI GetFileAttributesW ( LPCWSTR  lpFileName)

Definition at line 802 of file fileinfo.c.

803 {
808 
809  /* Get the NT path name */
811  {
814  }
815 
816  /* Prepare for querying attributes */
819  NULL, NULL);
820  /* Simply query attributes */
822  if (!NT_SUCCESS(Status))
823  {
824  /* It failed? Is it a DOS device? */
826  {
827  return FILE_ATTRIBUTE_ARCHIVE;
828  }
829 
830  /* Set the error otherwise */
833  }
834 
835  /* Return the file attributes */
836  return FileInformation.FileAttributes;
837 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
LONG NTSTATUS
Definition: precomp.h:26
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
Status
Definition: gdiplustypes.h:24
struct _FileName FileName
Definition: fatprocs.h:884
NTSTATUS NTAPI NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_BASIC_INFORMATION FileInformation)
Definition: file.c:3977
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
NTSYSAPI ULONG NTAPI RtlIsDosDeviceName_U(_In_ PCWSTR Name)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

Referenced by _waccess(), _wchmod(), _wmktemp(), _wtmpnam(), ACTION_AppSearchComponents(), ACTION_AppSearchDr(), ACTION_CheckDirectory(), ACTION_ResolveSource(), ACTION_SearchDirectory(), AddSubst(), app_search_file(), cabinet_copy_file(), cabinet_next_cabinet(), cache_QueryAssemblyInfo(), calculate_file_cost(), calculate_install_state(), CJournaledTestList::CJournaledTestList(), BtrfsRecv::cmd_removexattr(), BtrfsRecv::cmd_rmdir(), BtrfsRecv::cmd_setxattr(), BtrfsRecv::cmd_truncate(), BtrfsRecv::cmd_unlink(), BtrfsRecv::cmd_write(), compat_isdir(), copy_file(), copy_folder(), create_file(), create_fileW(), create_temp_dir(), CreateProcessInternalW(), delete_fileW(), DELNODE_recurse_dirtree(), do_file_copyW(), BtrfsRecv::do_recv(), DoEntry(), file_exists(), file_existsW(), file_get_Attributes(), FileMoniker_CreateFromDisplayName(), filesys_FileExists(), filesys_FolderExists(), filesys_GetFolder(), find_mono_dll(), find_published_source(), find_runtimes(), FinishDlgProc(), CFileDefExt::GeneralPageProc(), get_empty_cddrive(), get_fusion_filename(), get_local_package(), get_working_dir(), CConfiguration::GetConfigurationFromFile(), GetFileAttributesA(), GetLongPathNameW(), GetShortPathNameW(), GetTempFileNameW(), GetVersionFromFileExW(), IAssemblyCacheImpl_InstallAssembly(), IntDeleteRecursive(), is_directory(), ITERATE_MoveFiles(), LayoutList_Create(), LoadUserProfileW(), LocalScheduleJob(), MainWnd_OnInstall(), msi_create_temp_file(), msi_export_stream(), MSI_GetComponentPath(), msi_move_file(), MSI_OpenPackageW(), MSI_OpenProductW(), msi_resolve_file_source(), MSI_SetTargetPathW(), NewActionDlg_OnOK(), CFileDefExt::OnFolderCustApply(), open_package(), parse_file_list(), PathFileExistsAndAttributesW(), PathFileExistsW(), PathIsDirectoryW(), PathIsSystemFolderW(), PathMakeSystemFolderW(), PathUnmakeSystemFolderW(), pendingRename(), PickIconDlg(), pLoadImage(), ready_media(), RecycleBin5_RecycleBin5_DeleteFile(), RecycleBin5File_Constructor(), RecycleBin5File_RecycleBinFile_GetAttributes(), RecycleBin5File_RecycleBinFile_GetFileSize(), RecycleBin5File_RecycleBinFile_GetLastModificationTime(), resolve_filename(), RunDlg_GetParentDir(), SdbpFileExists(), anonymous_namespace{settingsdlg.cpp}::SettingsDlgProc(), SetupPromptForDiskW(), SHELL_ExecuteW(), SHELL_ExistsFileW(), SHELL_FindExecutable(), shell_item_exists(), SHELL_translate_idlist(), ShellExecCmdLine(), SHGetFileInfoW(), SHGetFolderPathAndSubDirW(), SHGetNewLinkInfoW(), SHNotifyCopyFileW(), SHNotifyDeleteFileW(), SHNotifyMoveFileW(), SHNotifyRemoveDirectoryW(), ShowCreateShortcutWizard(), SHPathPrepareForWriteW(), START_TEST(), StartInstaller(), test_CopyFolder(), test_file_link_information(), test_file_rename_information(), test_GetFile(), test_junction_points(), test_knownFolders(), test_LZOpenFileW(), test_NtCreateFile(), CDownloadManager::ThreadFunc(), WelcomeDlgProc(), XCOPY_DoCopy(), XCOPY_ProcessDestParm(), and XCOPY_ProcessSourceParm().

◆ GetFileInformationByHandle()

BOOL WINAPI GetFileInformationByHandle ( HANDLE  hFile,
LPBY_HANDLE_FILE_INFORMATION  lpFileInformation 
)

Definition at line 608 of file fileinfo.c.

610 {
611  struct
612  {
613  FILE_FS_VOLUME_INFORMATION FileFsVolume;
614  WCHAR Name[255];
615  }
616  FileFsVolume;
617 
618  FILE_BASIC_INFORMATION FileBasic;
619  FILE_INTERNAL_INFORMATION FileInternal;
620  FILE_STANDARD_INFORMATION FileStandard;
621  NTSTATUS errCode;
623 
625  {
627  return FALSE;
628  }
629 
630  errCode = NtQueryInformationFile(hFile,
631  &IoStatusBlock,
632  &FileBasic,
633  sizeof(FILE_BASIC_INFORMATION),
635  if (!NT_SUCCESS(errCode))
636  {
637  BaseSetLastNTError(errCode);
638  return FALSE;
639  }
640 
641  lpFileInformation->dwFileAttributes = (DWORD)FileBasic.FileAttributes;
642 
643  lpFileInformation->ftCreationTime.dwHighDateTime = FileBasic.CreationTime.u.HighPart;
644  lpFileInformation->ftCreationTime.dwLowDateTime = FileBasic.CreationTime.u.LowPart;
645 
646  lpFileInformation->ftLastAccessTime.dwHighDateTime = FileBasic.LastAccessTime.u.HighPart;
647  lpFileInformation->ftLastAccessTime.dwLowDateTime = FileBasic.LastAccessTime.u.LowPart;
648 
649  lpFileInformation->ftLastWriteTime.dwHighDateTime = FileBasic.LastWriteTime.u.HighPart;
650  lpFileInformation->ftLastWriteTime.dwLowDateTime = FileBasic.LastWriteTime.u.LowPart;
651 
652  errCode = NtQueryInformationFile(hFile,
653  &IoStatusBlock,
654  &FileInternal,
657  if (!NT_SUCCESS(errCode))
658  {
659  BaseSetLastNTError(errCode);
660  return FALSE;
661  }
662 
663  lpFileInformation->nFileIndexHigh = FileInternal.IndexNumber.u.HighPart;
664  lpFileInformation->nFileIndexLow = FileInternal.IndexNumber.u.LowPart;
665 
667  &IoStatusBlock,
668  &FileFsVolume,
669  sizeof(FileFsVolume),
671  if (!NT_SUCCESS(errCode))
672  {
673  BaseSetLastNTError(errCode);
674  return FALSE;
675  }
676 
677  lpFileInformation->dwVolumeSerialNumber = FileFsVolume.FileFsVolume.VolumeSerialNumber;
678 
679  errCode = NtQueryInformationFile(hFile,
680  &IoStatusBlock,
681  &FileStandard,
684  if (!NT_SUCCESS(errCode))
685  {
686  BaseSetLastNTError(errCode);
687  return FALSE;
688  }
689 
690  lpFileInformation->nNumberOfLinks = FileStandard.NumberOfLinks;
691  lpFileInformation->nFileSizeHigh = FileStandard.EndOfFile.u.HighPart;
692  lpFileInformation->nFileSizeLow = FileStandard.EndOfFile.u.LowPart;
693 
694  return TRUE;
695 }
#define TRUE
Definition: types.h:120
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
#define DWORD
Definition: nt_native.h:44
DWORD dwHighDateTime
Definition: mapidefs.h:66
NTSTATUS NTAPI NtQueryVolumeInformationFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FsInformation, IN ULONG Length, IN FS_INFORMATION_CLASS FsInformationClass)
Definition: iofunc.c:3976
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define IsConsoleHandle(h)
Definition: console.h:14
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FileStandardInformation
Definition: propsheet.cpp:61
struct _LARGE_INTEGER::@2192 u
DWORD dwLowDateTime
Definition: mapidefs.h:65

Referenced by __is_regular_file(), _fstat64(), BtrfsPropSheet::apply_changes_file(), BtrfsPropSheet::check_file(), count_blocks(), ShellDirectory::fill_w32fdata_shell(), FTP_SendData(), get_open_info(), DriveVolume::GetClusterInfo(), IStream_fnStat(), MountDisk(), WinDirectory::read_directory(), ShellDirectory::read_directory(), read_directory_win(), ReflinkCopyW(), BtrfsPropSheet::set_cmdline(), test_CreateFileA(), test_file_id_information(), BtrfsSend::Thread(), and VfdOpenImage().

◆ GetFileSize()

DWORD WINAPI GetFileSize ( HANDLE  hFile,
LPDWORD  lpFileSizeHigh 
)

Definition at line 481 of file fileinfo.c.

483 {
484  NTSTATUS errCode;
485  FILE_STANDARD_INFORMATION FileStandard;
487 
488  errCode = NtQueryInformationFile(hFile,
489  &IoStatusBlock,
490  &FileStandard,
493  if (!NT_SUCCESS(errCode))
494  {
495  BaseSetLastNTError(errCode);
496  if ( lpFileSizeHigh == NULL )
497  {
498  return -1;
499  }
500  else
501  {
502  return 0;
503  }
504  }
505  if ( lpFileSizeHigh != NULL )
506  *lpFileSizeHigh = FileStandard.EndOfFile.u.HighPart;
507 
508  return FileStandard.EndOfFile.u.LowPart;
509 }
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FileStandardInformation
Definition: propsheet.cpp:61
struct _LARGE_INTEGER::@2192 u

Referenced by __file_size(), _tiffSizeProc(), ata_bblk(), BatchFile2Mem(), cache_container_open_index(), check_binary_file_data(), check_exe(), check_pe_exe(), compare_file_(), compare_mf_disk_bits(), create_mapping(), create_stream(), create_stream_on_file(), create_test_dll(), create_test_dll_sections(), CRYPT_FileNameOpenStoreW(), CRYPT_ReadBlobFromFile(), CryptCATOpen(), CryptSIPRetrieveSubjectGuid(), d3dx_include_from_file_open(), DECLARE_INTERFACE_(), DoImport(), DosCheckInput(), DosCreateFile(), DosCreateFileEx(), DosLoadDriver(), DosLoadExecutable(), DosOpenFile(), CShellCommandSetValue::Execute(), ATL::CRegObject::file_register(), file_register(), FileAsyncReader_Length(), FileLockBytesImpl_Stat(), FileOpen(), get_file_size(), get_pf_file_size(), get_script_from_file(), get_script_str(), getFileSize(), HANDLE_CustomType21_22(), ICO_ExtractIconExW(), IDirectXFileImpl_CreateEnumObject(), ImageAddCertificate(), ImageGetDigestStream(), IMAGEHLP_RecalculateChecksum(), ImageRemoveCertificate(), InitFont(), is_zero_length(), load_font(), load_script(), LoadCodePageData(), LoadDIBFromFile(), LoadFile(), CJournaledTestList::LoadJournalFile(), LoadTextFileToEdit(), map_file(), map_fileW(), map_view_of_file(), MapAndLoad(), MapFile(), MapFileAndCheckSumA(), MapFileAndCheckSumW(), MMIO_Open(), MountDisk(), MountFDI(), msi_get_disk_file_size(), msi_get_filehash(), msi_read_text_archive(), NLS_ReadFile(), OLECONVERT_WriteOLE20ToBuffer(), OpenColorProfileW(), parse_file(), PROFILE_Load(), pSetupOpenAndMapFileForRead(), query_image_section(), ReadJobShadowFile(), ReadRdpFile(), ReadText(), RECORD_StreamFromFile(), RecycleBin5_RecycleBin5_Delete(), RecycleBin5_RecycleBin5_DeleteFile(), RecycleBin5_RecycleBin5_Restore(), RecycleBin5Enum_RecycleBinEnumList_Next(), RecycleBin5File_RecycleBinFile_GetFileSize(), RetrieveQuote(), SaveDIBToFile(), CHttpClient::SendFile(), sha_check(), StgOpenStorage(), test_CopyFile2(), test_CopyFileA(), test_http_cache(), test_NtQuerySection(), test_overwrite(), test_ReadConsole(), test_ReplaceFileA(), test_TransmitFile(), testFileStore(), TLB_Mapping_Open(), VfdCheckImageFile(), VfdOpenImage(), WINTRUST_GetSignedMsgFromCatFile(), wmain(), and WriteJobShadowFile().

◆ GetFileSizeEx()

BOOL WINAPI GetFileSizeEx ( HANDLE  hFile,
PLARGE_INTEGER  lpFileSize 
)

Definition at line 517 of file fileinfo.c.

521 {
522  NTSTATUS errCode;
523  FILE_STANDARD_INFORMATION FileStandard;
525 
526  errCode = NtQueryInformationFile(hFile,
527  &IoStatusBlock,
528  &FileStandard,
531  if (!NT_SUCCESS(errCode))
532  {
533  BaseSetLastNTError(errCode);
534  return FALSE;
535  }
536  if (lpFileSize)
537  *lpFileSize = FileStandard.EndOfFile;
538 
539  return TRUE;
540 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FileStandardInformation
Definition: propsheet.cpp:61

◆ GetFileTime()

BOOL WINAPI GetFileTime ( IN HANDLE  hFile,
OUT LPFILETIME lpCreationTime  OPTIONAL,
OUT LPFILETIME lpLastAccessTime  OPTIONAL,
OUT LPFILETIME lpLastWriteTime  OPTIONAL 
)

Definition at line 1046 of file fileinfo.c.

1050 {
1051  NTSTATUS Status;
1053  FILE_BASIC_INFORMATION FileBasic;
1054 
1055  if(IsConsoleHandle(hFile))
1056  {
1058  return FALSE;
1059  }
1060 
1062  &IoStatusBlock,
1063  &FileBasic,
1064  sizeof(FILE_BASIC_INFORMATION),
1066  if (!NT_SUCCESS(Status))
1067  {
1069  return FALSE;
1070  }
1071 
1072  if (lpCreationTime)
1073  {
1074  lpCreationTime->dwLowDateTime = FileBasic.CreationTime.LowPart;
1075  lpCreationTime->dwHighDateTime = FileBasic.CreationTime.HighPart;
1076  }
1077 
1078  if (lpLastAccessTime)
1079  {
1080  lpLastAccessTime->dwLowDateTime = FileBasic.LastAccessTime.LowPart;
1081  lpLastAccessTime->dwHighDateTime = FileBasic.LastAccessTime.HighPart;
1082  }
1083 
1084  if (lpLastWriteTime)
1085  {
1086  lpLastWriteTime->dwLowDateTime = FileBasic.LastWriteTime.LowPart;
1087  lpLastWriteTime->dwHighDateTime = FileBasic.LastWriteTime.HighPart;
1088  }
1089 
1090  return TRUE;
1091 }
#define TRUE
Definition: types.h:120
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IsConsoleHandle(h)
Definition: console.h:14
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
ULONG LowPart
Definition: typedefs.h:104
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75

Referenced by AddKnownDriverToList(), copy(), DosInt21h(), CZipExtract::Extract(), File_RetrieveEncodedObjectW(), GetFileModifyTime(), CCabinet::GetFileTimes(), GetSetFileTimestamp(), LoadDIBFromFile(), LZCopy(), PROFILE_FlushFile(), PROFILE_Open(), ProtocolStream_Stat(), RecycleBin5File_RecycleBinFile_GetLastModificationTime(), replace(), SaveDIBToFile(), SOFTPUB_OpenFile(), test_CopyFile2(), test_CopyFileA(), Test_LongTests(), test_RealizationInfo(), test_ReplaceFileA(), Test_VeryLongTests(), wmain(), and XCOPY_DoCopy().

◆ GetFileType()

DWORD WINAPI GetFileType ( HANDLE  hFile)

Definition at line 419 of file fileinfo.c.

420 {
422  IO_STATUS_BLOCK StatusBlock;
424 
425  /* Get real handle */
427 
428  /* Check for console handle */
429  if (IsConsoleHandle(hFile))
430  {
432  return FILE_TYPE_CHAR;
433  }
434 
436  &StatusBlock,
437  &DeviceInfo,
440  if (!NT_SUCCESS(Status))
441  {
443  return FILE_TYPE_UNKNOWN;
444  }
445 
446  switch (DeviceInfo.DeviceType)
447  {
448  case FILE_DEVICE_CD_ROM:
452  case FILE_DEVICE_DFS:
453  case FILE_DEVICE_DISK:
456  return FILE_TYPE_DISK;
457 
459  case FILE_DEVICE_MOUSE:
460  case FILE_DEVICE_NULL:
462  case FILE_DEVICE_PRINTER:
464  case FILE_DEVICE_SCREEN:
465  case FILE_DEVICE_SOUND:
466  case FILE_DEVICE_MODEM:
467  return FILE_TYPE_CHAR;
468 
470  return FILE_TYPE_PIPE;
471  }
472 
473  return FILE_TYPE_UNKNOWN;
474 }
#define FILE_DEVICE_DISK
Definition: winioctl.h:112
#define FILE_TYPE_DISK
Definition: winbase.h:256
#define FILE_DEVICE_SCREEN
Definition: winioctl.h:133
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:122
LONG NTSTATUS
Definition: precomp.h:26
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
#define FILE_DEVICE_VIRTUAL_DISK
Definition: winioctl.h:141
#define FILE_DEVICE_NULL
Definition: winioctl.h:126
#define FILE_TYPE_UNKNOWN
Definition: winbase.h:255
#define FILE_DEVICE_MODEM
Definition: winioctl.h:148
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:107
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:109
#define FILE_TYPE_CHAR
Definition: winbase.h:257
NTSTATUS NTAPI NtQueryVolumeInformationFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock, OUT PVOID FsInformation, IN ULONG Length, IN FS_INFORMATION_CLASS FsInformationClass)
Definition: iofunc.c:3976
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:113
#define FILE_DEVICE_DATALINK
Definition: winioctl.h:110
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define FILE_DEVICE_DFS
Definition: winioctl.h:111
struct _DeviceInfo DeviceInfo
#define FILE_DEVICE_PARALLEL_PORT
Definition: winioctl.h:127
#define FILE_DEVICE_MOUSE
Definition: winioctl.h:120
#define IsConsoleHandle(h)
Definition: console.h:14
#define FILE_DEVICE_SOUND
Definition: winioctl.h:134
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
#define FILE_TYPE_PIPE
Definition: winbase.h:258
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
Definition: winioctl.h:108
#define FILE_DEVICE_SERIAL_PORT
Definition: serial.c:44
#define FILE_DEVICE_KEYBOARD
Definition: winioctl.h:116
#define FILE_DEVICE_PRINTER
Definition: winioctl.h:129

Referenced by _fstat64(), _open_osfhandle(), _wsopen_s(), FormatOutput(), getpass(), IsConsoleHandle(), IsTTYHandle(), main(), msvcrt_init_io(), run_open_osfhandle(), test_GetFileType(), and wmain().

◆ SetEndOfFile()

BOOL WINAPI SetEndOfFile ( HANDLE  hFile)

Definition at line 1154 of file fileinfo.c.

1155 {
1157  FILE_END_OF_FILE_INFORMATION EndOfFileInfo;
1158  FILE_ALLOCATION_INFORMATION FileAllocationInfo;
1159  FILE_POSITION_INFORMATION FilePosInfo;
1160  NTSTATUS Status;
1161 
1162  if(IsConsoleHandle(hFile))
1163  {
1165  return FALSE;
1166  }
1167 
1168  //get current position
1170  hFile,
1171  &IoStatusBlock,
1172  &FilePosInfo,
1173  sizeof(FILE_POSITION_INFORMATION),
1175  );
1176 
1177  if (!NT_SUCCESS(Status)){
1179  return FALSE;
1180  }
1181 
1182  EndOfFileInfo.EndOfFile.QuadPart = FilePosInfo.CurrentByteOffset.QuadPart;
1183 
1184  /*
1185  NOTE:
1186  This call is not supposed to free up any space after the eof marker
1187  if the file gets truncated. We have to deallocate the space explicitly afterwards.
1188  But...most file systems dispatch both FileEndOfFileInformation
1189  and FileAllocationInformation as they were the same command.
1190 
1191  */
1193  hFile,
1194  &IoStatusBlock, //out
1195  &EndOfFileInfo,
1198  );
1199 
1200  if (!NT_SUCCESS(Status)){
1202  return FALSE;
1203  }
1204 
1205  FileAllocationInfo.AllocationSize.QuadPart = FilePosInfo.CurrentByteOffset.QuadPart;
1206 
1207 
1209  hFile,
1210  &IoStatusBlock, //out
1211  &FileAllocationInfo,
1214  );
1215 
1216  if (!NT_SUCCESS(Status)){
1218  return FALSE;
1219  }
1220 
1221  return TRUE;
1222 
1223 }
#define TRUE
Definition: types.h:120
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
LARGE_INTEGER AllocationSize
Definition: winternl.h:688
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define IsConsoleHandle(h)
Definition: console.h:14
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:2934
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by _chsize_s(), _hwrite(), cache_container_set_size(), BtrfsRecv::cmd_clone(), BtrfsRecv::cmd_truncate(), create_file(), create_file_data(), create_test_dll(), DosWriteFile(), FileLockBytesImpl_SetSize(), ImageRemoveCertificate(), IStream_fnSetSize(), query_image_section(), RecycleBin5_RecycleBin5_Delete(), RecycleBin5_RecycleBin5_DeleteFile(), RecycleBin5_RecycleBin5_Restore(), ReplaceFileW(), resize_mapping(), send_subvol(), set_image_size(), test_CreateFileMapping_protection(), test_filemap_security(), test_GetMappedFileName(), test_mapping(), test_MapViewOfFile(), test_NtAreMappedFilesTheSame(), test_NtMapViewOfSection(), test_read_write(), test_ResolveDelayLoadedAPI(), test_SetFileValidData(), Test_Truncate(), BtrfsSend::Thread(), VfdCreateImageFile(), and VfdSaveImage().

◆ SetFileAttributesA()

BOOL WINAPI SetFileAttributesA ( LPCSTR  lpFileName,
DWORD  dwFileAttributes 
)

Definition at line 926 of file fileinfo.c.

929 {
930  PWCHAR FileNameW;
931 
932  if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
933  return FALSE;
934 
935  return SetFileAttributesW(FileNameW, dwFileAttributes);
936 }
BOOL WINAPI SetFileAttributesW(LPCWSTR lpFileName, DWORD dwFileAttributes)
Definition: fileinfo.c:944
uint16_t * PWCHAR
Definition: typedefs.h:54
PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc)
Definition: fileinfo.c:22
DWORD dwFileAttributes
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

Referenced by _chmod(), check_ini_file_attr(), cleanup_test(), doChild(), DosInt21h(), PathUnmakeSystemFolderA(), test__creat(), test__hread(), test__lcreat(), test_AddDelBackupEntry(), test_copy(), test_CryptCATAdminAddRemoveCatalog(), test_Extract(), test_file_disposition_information(), test_FileSecurity(), test_FindFirstChangeNotification(), test_keep_attributes(), test_LocalizedNames(), test_Mapfile_createtemp(), and test_ReplaceFileA().

◆ SetFileAttributesByHandle()

BOOL WINAPI SetFileAttributesByHandle ( IN HANDLE  hFile,
IN DWORD  dwFileAttributes,
IN DWORD  dwFlags 
)

Definition at line 880 of file fileinfo.c.

883 {
884  FILE_BASIC_INFORMATION FileBasic;
887 
889 
890  if (IsConsoleHandle(hFile))
891  {
893  return FALSE;
894  }
895 
897  &IoStatusBlock,
898  &FileBasic,
899  sizeof(FileBasic),
901  if (NT_SUCCESS(Status))
902  {
903  FileBasic.FileAttributes = dwFileAttributes;
904 
906  &IoStatusBlock,
907  &FileBasic,
908  sizeof(FileBasic),
910  }
911 
912  if (!NT_SUCCESS(Status))
913  {
915  return FALSE;
916  }
917 
918  return TRUE;
919 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define IsConsoleHandle(h)
Definition: console.h:14
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
DWORD dwFileAttributes
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:2934

◆ SetFileAttributesW()

BOOL WINAPI SetFileAttributesW ( LPCWSTR  lpFileName,
DWORD  dwFileAttributes 
)

Definition at line 944 of file fileinfo.c.

946 {
948  PWSTR PathUBuffer;
950  UNICODE_STRING NtPathU;
952  RTL_RELATIVE_NAME_U RelativeName;
955 
956  /* Get relative name */
957  if (!RtlDosPathNameToRelativeNtPathName_U(lpFileName, &NtPathU, NULL, &RelativeName))
958  {
960  return FALSE;
961  }
962 
963  /* Save buffer to allow later freeing */
964  PathUBuffer = NtPathU.Buffer;
965 
966  /* If we have relative name (and root dir), use them instead */
967  if (RelativeName.RelativeName.Length != 0)
968  {
969  NtPathU.Length = RelativeName.RelativeName.Length;
970  NtPathU.MaximumLength = RelativeName.RelativeName.MaximumLength;
971  NtPathU.Buffer = RelativeName.RelativeName.Buffer;
972  }
973  else
974  {
975  RelativeName.ContainingDirectory = NULL;
976  }
977 
978  /* Prepare the object attribute for opening the file */
981  RelativeName.ContainingDirectory, NULL);
982 
983  /* Attempt to open the file, while supporting reparse point */
988  /* If opening failed, check whether it was because of reparse point support */
989  if (!NT_SUCCESS(Status))
990  {
991  /* Nope, just quit */
993  {
994  RtlReleaseRelativeName(&RelativeName);
995  RtlFreeHeap(RtlGetProcessHeap(), 0, PathUBuffer);
997 
998  return FALSE;
999  }
1000 
1001  /* Yes, retry without */
1006  if (!NT_SUCCESS(Status))
1007  {
1008  RtlReleaseRelativeName(&RelativeName);
1009  RtlFreeHeap(RtlGetProcessHeap(), 0, PathUBuffer);
1011 
1012  return FALSE;
1013  }
1014  }
1015 
1016  /* We don't need strings anylonger */
1017  RtlReleaseRelativeName(&RelativeName);
1018  RtlFreeHeap(RtlGetProcessHeap(), 0, PathUBuffer);
1019 
1020  /* Zero our structure, we'll only set file attributes */
1022  /* Set the attributes, filtering only allowed attributes, and forcing normal attribute */
1024 
1025  /* Finally, set the attributes */
1028  /* Close the file */
1030 
1031  /* If it failed, set the error and fail */
1032  if (!NT_SUCCESS(Status))
1033  {
1035 
1036  return FALSE;
1037  }
1038 
1039  return TRUE;
1040 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
#define TRUE
Definition: types.h:120
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
uint16_t * PWSTR
Definition: typedefs.h:54
HANDLE ContainingDirectory
Definition: rtltypes.h:1375
VOID NTAPI RtlReleaseRelativeName(_In_ PRTL_RELATIVE_NAME_U RelativeName)
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:603
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
#define ZeroMemory
Definition: winbase.h:1635
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
#define FILE_SHARE_READ
Definition: compat.h:125
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToRelativeNtPathName_U(_In_ PCWSTR DosName, _Out_ PUNICODE_STRING NtName, _Out_ PCWSTR *PartName, _Out_ PRTL_RELATIVE_NAME_U RelativeName)
HANDLE FileHandle
Definition: stats.c:38
smooth NULL
Definition: ftsmooth.c:416
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
Definition: file.c:3951
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:126
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define SYNCHRONIZE
Definition: nt_native.h:61
Status
Definition: gdiplustypes.h:24
#define FILE_OPEN_FOR_BACKUP_INTENT
Definition: from_kernel.h:42
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
DWORD dwFileAttributes
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
UNICODE_STRING RelativeName
Definition: rtltypes.h:1374
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106
#define FILE_ATTRIBUTE_VALID_SET_FLAGS
Definition: nt_native.h:715
#define FILE_OPEN_REPARSE_POINT
Definition: from_kernel.h:46
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:2934
_In_ LPCSTR lpFileName
Definition: winbase.h:3011

Referenced by _wchmod(), ACTION_RemoveFiles(), AddDelBackupEntryW(), BasepCopyFileExW(), cabinet_copy_file(), BtrfsRecv::cmd_removexattr(), BtrfsRecv::cmd_rmdir(), BtrfsRecv::cmd_setxattr(), BtrfsRecv::cmd_truncate(), BtrfsRecv::cmd_unlink(), BtrfsRecv::cmd_write(), copy_file(), copy_install_file(), CreateStandardProfile(), CryptCATAdminAddCatalog(), delete_directory(), delete_file(), DELNODE_recurse_dirtree(), BtrfsRecv::do_recv(), file_put_Attributes(), CFileDefExt::GeneralPageProc(), InitializeSetupActionLog(), IntDeleteRecursive(), MoveFileWithProgressW(), CFileDefExt::OnFolderCustApply(), PathMakeSystemFolderW(), PathUnmakeSystemFolderW(), RecursiveRemoveDir(), RecycleBin5_Create(), SetFileAttributesA(), SetupInitializeFileLogW(), SHGetFolderPathAndSubDirW(), SHNotifyCopyFileW(), SHNotifyDeleteFileW(), SHNotifyMoveFileW(), SHNotifyRemoveDirectoryW(), START_TEST(), test_NtCreateFile(), test_readonly(), test_ReplaceFileW(), and XCOPY_DoCopy().

◆ SetFilePointer()

DWORD WINAPI DECLSPEC_HOTPATCH SetFilePointer ( HANDLE  hFile,
LONG  lDistanceToMove,
PLONG  lpDistanceToMoveHigh,
DWORD  dwMoveMethod 
)

Definition at line 204 of file fileinfo.c.

208 {
209  FILE_POSITION_INFORMATION FilePosition;
210  FILE_STANDARD_INFORMATION FileStandard;
211  NTSTATUS errCode;
213  LARGE_INTEGER Distance;
214 
215  TRACE("SetFilePointer(hFile %p, lDistanceToMove %d, dwMoveMethod %lu)\n",
216  hFile,lDistanceToMove,dwMoveMethod);
217 
219  {
222  }
223 
224  if (lpDistanceToMoveHigh)
225  {
226  Distance.u.HighPart = *lpDistanceToMoveHigh;
227  Distance.u.LowPart = lDistanceToMove;
228  }
229  else
230  {
231  Distance.QuadPart = lDistanceToMove;
232  }
233 
234  switch(dwMoveMethod)
235  {
236  case FILE_CURRENT:
237  errCode = NtQueryInformationFile(hFile,
238  &IoStatusBlock,
239  &FilePosition,
242  FilePosition.CurrentByteOffset.QuadPart += Distance.QuadPart;
243  if (!NT_SUCCESS(errCode))
244  {
245  if (lpDistanceToMoveHigh != NULL)
246  *lpDistanceToMoveHigh = -1;
247  BaseSetLastNTError(errCode);
249  }
250  break;
251  case FILE_END:
252  errCode = NtQueryInformationFile(hFile,
253  &IoStatusBlock,
254  &FileStandard,
257  FilePosition.CurrentByteOffset.QuadPart =
258  FileStandard.EndOfFile.QuadPart + Distance.QuadPart;
259  if (!NT_SUCCESS(errCode))
260  {
261  if (lpDistanceToMoveHigh != NULL)
262  *lpDistanceToMoveHigh = -1;
263  BaseSetLastNTError(errCode);
265  }
266  break;
267  case FILE_BEGIN:
268  FilePosition.CurrentByteOffset.QuadPart = Distance.QuadPart;
269  break;
270  default:
273  }
274 
275  if(FilePosition.CurrentByteOffset.QuadPart < 0)
276  {
279  }
280 
281  if (lpDistanceToMoveHigh == NULL && FilePosition.CurrentByteOffset.HighPart != 0)
282  {
283  /* If we're moving the pointer outside of the 32 bit boundaries but
284  the application only passed a 32 bit value we need to bail out! */
287  }
288 
289  errCode = NtSetInformationFile(hFile,
290  &IoStatusBlock,
291  &FilePosition,
294  if (!NT_SUCCESS(errCode))
295  {
296  if (lpDistanceToMoveHigh != NULL)
297  *lpDistanceToMoveHigh = -1;
298 
299  BaseSetLastNTError(errCode);
301  }
302 
303  if (lpDistanceToMoveHigh != NULL)
304  {
305  *lpDistanceToMoveHigh = FilePosition.CurrentByteOffset.u.HighPart;
306  }
307 
308  if (FilePosition.CurrentByteOffset.u.LowPart == MAXDWORD)
309  {
310  /* The value of -1 is valid here, especially when the new
311  file position is greater than 4 GB. Since NtSetInformationFile
312  succeeded we never set an error code and we explicitly need
313  to clear a previously set error code in this case, which
314  an application will check if INVALID_SET_FILE_POINTER is returned! */
316  }
317 
318  return FilePosition.CurrentByteOffset.u.LowPart;
319 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define INVALID_SET_FILE_POINTER
Definition: winbase.h:115
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FILE_CURRENT
Definition: winbase.h:113
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
#define MAXDWORD
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define TRACE(s)
Definition: solgame.cpp:4
#define FILE_END
Definition: winbase.h:114
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define IsConsoleHandle(h)
Definition: console.h:14
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERROR_NEGATIVE_SEEK
Definition: winerror.h:203
#define FILE_BEGIN
Definition: winbase.h:112
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FileStandardInformation
Definition: propsheet.cpp:61
struct _LARGE_INTEGER::@2192 u
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:2934
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by _eof(), _llseek(), _locking(), _lseeki64(), _tiffSeekProc(), append_file(), append_file_test(), BatchFile2Mem(), cabinet_seek(), cache_container_set_size(), check_bom(), child_process(), ClipboardReadMemoryBlock(), ClipboardWriteMemory(), CloseEnhMetaFile(), BtrfsRecv::cmd_clone(), BtrfsRecv::cmd_truncate(), BtrfsRecv::cmd_write(), CmosCleanup(), CmosInitialize(), compare_file2(), copy(), create_file(), create_file_data(), create_test_dll(), create_test_dll_sections(), CRYPT_WriteSerializedStoreToFile(), CryptSIPRetrieveSubjectGuid(), DoOpenFile(), DosCheckInput(), DosSeekFile(), DoWriteFile(), dump_memory_info(), DumpMemoryRaw(), DumpMemoryTxt(), ExtractZipImage(), ExtractZipInfo(), fci_seek(), fdi_seek(), FileGetString(), FNSEEK(), get_file_size(), GetProtoGetNextEnt(), ImageAddCertificate(), ImageEnumerateCertificates(), ImageGetCertificateData(), ImageGetCertificateHeader(), IMAGEHLP_GetCertificateOffset(), IMAGEHLP_GetNTHeaders(), IMAGEHLP_RecalculateChecksum(), IMAGEHLP_SetSecurityDirOffset(), ImageRemoveCertificate(), InternalGetBinaryType(), InternalIsOS2OrOldWin(), IStream_fnSeek(), IStream_fnSetSize(), load_ttf_name_id(), LogToFile(), main(), MFDRV_CloseMetaFile(), MountFDI(), MountHDD(), MySetFilePointerEx(), open_file_test(), PerformRedirection(), process_stabs(), pSetupDebugPrint(), read_file(), read_i(), read_utf8(), ReadClipboardFile(), ReadUrlCacheEntryStream(), ReadVolumeSector(), RecycleBin5_RecycleBin5_Delete(), RecycleBin5_RecycleBin5_DeleteFile(), RecycleBin5_RecycleBin5_Restore(), resize_mapping(), sc_cb_lseek(), SeekDisk(), set_file_pointer(), set_image_size(), SetupOpenLog(), shgfi_get_exe_type(), SOFTPUB_HashPEFile(), test_create_db_imp(), test_CreateFileMapping_protection(), test_ExitProcess(), test_file_access(), test_filemap_security(), test_GetMappedFileName(), test_import_resolution(), test_mapping(), test_MapViewOfFile(), test_NtAreMappedFilesTheSame(), test_NtMapViewOfSection(), test_offset_in_overlapped_structure(), test_read_write(), test_ResolveDelayLoadedAPI(), test_section_access(), test_SetFileValidData(), test_TransmitFile(), Test_Truncate(), udf_lseek64(), UDFGetBlockSize(), UDFPhReadSynchronous(), UDFPhWriteSynchronous(), CJournaledTestList::UpdateJournal(), VfdFormatMedia(), VfdOpenImage(), VfdSaveImage(), WINTRUST_GetSignedMsgFromCabFile(), wmain(), write(), writeat(), WriteClipboardFile(), WriteSdbFile(), and WriteVolumeSector().

◆ SetFilePointerEx()

BOOL WINAPI SetFilePointerEx ( HANDLE  hFile,
LARGE_INTEGER  liDistanceToMove,
PLARGE_INTEGER  lpNewFilePointer,
DWORD  dwMoveMethod 
)

Definition at line 327 of file fileinfo.c.

331 {
334  FILE_POSITION_INFORMATION FilePosition;
335  FILE_STANDARD_INFORMATION FileStandard;
336 
337  if (IsConsoleHandle(hFile))
338  {
340  return FALSE;
341  }
342 
343  switch (dwMoveMethod)
344  {
345  case FILE_CURRENT:
346  {
348  &FilePosition,
351  if (!NT_SUCCESS(Status))
352  {
354  return FALSE;
355  }
356 
357  FilePosition.CurrentByteOffset.QuadPart += liDistanceToMove.QuadPart;
358  break;
359  }
360 
361  case FILE_END:
362  {
364  &FileStandard,
367  if (!NT_SUCCESS(Status))
368  {
370  return FALSE;
371  }
372 
373  FilePosition.CurrentByteOffset.QuadPart = FileStandard.EndOfFile.QuadPart +
374  liDistanceToMove.QuadPart;
375  break;
376  }
377 
378  case FILE_BEGIN:
379  {
380  FilePosition.CurrentByteOffset.QuadPart = liDistanceToMove.QuadPart;
381  break;
382  }
383 
384  default:
385  {
387  return FALSE;
388  }
389  }
390 
391  if (FilePosition.CurrentByteOffset.QuadPart < 0)
392  {
394  return FALSE;
395  }
396 
397  Status = NtSetInformationFile(hFile, &IoStatusBlock, &FilePosition,
400  if (!NT_SUCCESS(Status))
401  {
403  return FALSE;
404  }
405 
406  if (lpNewFilePointer != NULL)
407  {
408  *lpNewFilePointer = FilePosition.CurrentByteOffset;
409  }
410 
411  return TRUE;
412 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define FILE_CURRENT
Definition: winbase.h:113
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
smooth NULL
Definition: ftsmooth.c:416
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define FILE_END
Definition: winbase.h:114
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define SetLastError(x)
Definition: compat.h:409
#define IsConsoleHandle(h)
Definition: console.h:14
NTSTATUS NTAPI NtQueryInformationFile(HANDLE hFile, PIO_STATUS_BLOCK io, PVOID ptr, ULONG len, FILE_INFORMATION_CLASS FileInformationClass)
_In_ HANDLE hFile
Definition: mswsock.h:90
#define ERROR_NEGATIVE_SEEK
Definition: winerror.h:203
Status
Definition: gdiplustypes.h:24
#define FILE_BEGIN
Definition: winbase.h:112
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define FileStandardInformation
Definition: propsheet.cpp:61
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:2934
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by _chm_fetch_bytes(), BestFit_Write(), CryptSIPRetrieveSubjectGuid(), FileLockBytesImpl_ReadAt(), FileLockBytesImpl_SetSize(), FileLockBytesImpl_WriteAt(), MySetFilePointerEx(), ProtocolStream_Seek(), query_image_section(), textstream_get_AtEndOfStream(), textstream_Read(), and textstream_ReadAll().

◆ SetFileTime()

BOOL WINAPI SetFileTime ( IN HANDLE  hFile,
CONST FILETIME *lpCreationTime  OPTIONAL,
CONST FILETIME *lpLastAccessTime  OPTIONAL,
CONST FILETIME *lpLastWriteTime  OPTIONAL 
)

Definition at line 1098 of file fileinfo.c.

1102 {
1103  NTSTATUS Status;
1105  FILE_BASIC_INFORMATION FileBasic;
1106 
1107  if(IsConsoleHandle(hFile))
1108  {
1110  return FALSE;
1111  }
1112 
1113  memset(&FileBasic, 0, sizeof(FILE_BASIC_INFORMATION));
1114 
1115  if (lpCreationTime)
1116  {
1117  FileBasic.CreationTime.LowPart = lpCreationTime->dwLowDateTime;
1118  FileBasic.CreationTime.HighPart = lpCreationTime->dwHighDateTime;
1119  }
1120 
1121  if (lpLastAccessTime)
1122  {
1123  FileBasic.LastAccessTime.LowPart = lpLastAccessTime->dwLowDateTime;
1124  FileBasic.LastAccessTime.HighPart = lpLastAccessTime->dwHighDateTime;
1125  }
1126 
1127  if (lpLastWriteTime)
1128  {
1129  FileBasic.LastWriteTime.LowPart = lpLastWriteTime->dwLowDateTime;
1130  FileBasic.LastWriteTime.HighPart = lpLastWriteTime->dwHighDateTime;
1131  }
1132 
1134  &IoStatusBlock,
1135  &FileBasic,
1136  sizeof(FILE_BASIC_INFORMATION),
1138  if (!NT_SUCCESS(Status))
1139  {
1141  return FALSE;
1142  }
1143 
1144  return TRUE;
1145 }
#define TRUE
Definition: types.h:120
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:231
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IsConsoleHandle(h)
Definition: console.h:14
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
ULONG LowPart
Definition: typedefs.h:104
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
#define memset(x, y, z)
Definition: compat.h:39
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:2934

Referenced by _futime(), cabinet_close_file_info(), copy(), DosInt21h(), CZipExtract::Extract(), CCabinet::ExtractFile(), fdi_notify_extract(), GetSetFileTimestamp(), LZCopy(), BtrfsContextMenu::reflink_copy(), reflink_copy2(), replace(), run_child_process(), test_CopyFile2(), test_CopyFileA(), test_CreateFile(), test_ReplaceFileA(), and TouchFileTimes().

◆ SetFileValidData()

BOOL WINAPI SetFileValidData ( HANDLE  hFile,
LONGLONG  ValidDataLength 
)

Definition at line 1231 of file fileinfo.c.

1235 {
1237  FILE_VALID_DATA_LENGTH_INFORMATION ValidDataLengthInformation;
1238  NTSTATUS Status;
1239 
1240  ValidDataLengthInformation.ValidDataLength.QuadPart = ValidDataLength;
1241 
1243  hFile,
1244  &IoStatusBlock, //out
1245  &ValidDataLengthInformation,
1248  );
1249 
1250  if (!NT_SUCCESS(Status)){
1252  return FALSE;
1253  }
1254 
1255  return TRUE;
1256 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ HANDLE hFile
Definition: mswsock.h:90
Status
Definition: gdiplustypes.h:24
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
NTSYSAPI NTSTATUS NTAPI NtSetInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
Definition: iofunc.c:2934
LONGLONG QuadPart
Definition: typedefs.h:112