ReactOS 0.4.15-dev-8100-g1887773
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)
 
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  )

◆ FlushFileBuffers()

BOOL WINAPI FlushFileBuffers ( IN HANDLE  hFile)

Definition at line 25 of file fileinfo.c.

26{
29
31
33 {
35 }
36
39 if (!NT_SUCCESS(Status))
40 {
42 return FALSE;
43 }
44 return TRUE;
45}
LONG NTSTATUS
Definition: precomp.h:26
BOOL WINAPI FlushConsoleInputBuffer(IN HANDLE hConsoleInput)
Definition: console.c:220
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
HANDLE TranslateStdHandle(IN HANDLE hHandle)
Definition: handle.c:19
Status
Definition: gdiplustypes.h:25
NTSTATUS NTAPI NtFlushBuffersFile(IN HANDLE FileHandle, OUT PIO_STATUS_BLOCK IoStatusBlock)
Definition: iofunc.c:1487
static OUT PIO_STATUS_BLOCK IoStatusBlock
Definition: pipe.c:75
_In_ HANDLE hFile
Definition: mswsock.h:90
DWORD BaseSetLastNTError(IN NTSTATUS Status)
Definition: reactos.cpp:166
#define IsConsoleHandle(h)
Definition: console.h:14

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 397 of file fileinfo.c.

399{
400 PWCHAR FileNameW;
401
402 if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
403 return INVALID_FILE_SIZE;
404
405 return GetCompressedFileSizeW(FileNameW, lpFileSizeHigh);
406}
DWORD WINAPI GetCompressedFileSizeW(LPCWSTR lpFileName, LPDWORD lpFileSizeHigh)
Definition: fileinfo.c:413
PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc)
Definition: fileutils.c:18
uint16_t * PWCHAR
Definition: typedefs.h:56
_In_ LPCSTR lpFileName
Definition: winbase.h:3071
#define INVALID_FILE_SIZE
Definition: winbase.h:548

◆ GetCompressedFileSizeW()

DWORD WINAPI GetCompressedFileSizeW ( LPCWSTR  lpFileName,
LPDWORD  lpFileSizeHigh 
)

Definition at line 413 of file fileinfo.c.

415{
416 FILE_COMPRESSION_INFORMATION FileCompression;
417 NTSTATUS errCode;
420
424 NULL,
427 NULL);
428
430 return INVALID_FILE_SIZE;
431
434 &FileCompression,
437
439
440 if (!NT_SUCCESS(errCode))
441 {
442 BaseSetLastNTError(errCode);
443 return INVALID_FILE_SIZE;
444 }
445
446 if(lpFileSizeHigh)
447 *lpFileSizeHigh = FileCompression.CompressedFileSize.u.HighPart;
448
450 return FileCompression.CompressedFileSize.u.LowPart;
451}
#define NO_ERROR
Definition: dderror.h:5
#define NULL
Definition: types.h:112
#define CloseHandle
Definition: compat.h:739
#define OPEN_EXISTING
Definition: compat.h:775
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define GENERIC_READ
Definition: compat.h:135
#define CreateFileW
Definition: compat.h:741
#define FILE_ATTRIBUTE_NORMAL
Definition: compat.h:137
#define FILE_SHARE_READ
Definition: compat.h:136
@ FileCompressionInformation
Definition: from_kernel.h:89
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
LARGE_INTEGER CompressedFileSize
Definition: iotypes.h:5849
struct _LARGE_INTEGER::@2299 u

Referenced by GetCompressedFileSizeA().

◆ GetFileAttributesA()

DWORD WINAPI GetFileAttributesA ( LPCSTR  lpFileName)

Definition at line 636 of file fileinfo.c.

637{
638 PWSTR FileNameW;
639
640 if (!lpFileName || !(FileNameW = FilenameA2W(lpFileName, FALSE)))
642
643 return GetFileAttributesW(FileNameW);
644}
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
uint16_t * PWSTR
Definition: typedefs.h:56
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23

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(), pf_exists(), register_service(), search_absolute_directory(), SHAddToRecentDocs(), shell_execute_(), shell_execute_ex_(), START_TEST(), system(), 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_DelNodeA(), 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_settargetpath(), test_SHGetFolderPathAndSubDirA(), test_summary_binary(), test_WritePrivateProfileString(), tmpnam(), VerInstallFileA(), VfdInstallDriver(), and xsltCheckFilename().

◆ GetFileAttributesByHandle()

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

Definition at line 694 of file fileinfo.c.

697{
698 FILE_BASIC_INFORMATION FileBasic;
701
703
705 {
707 return FALSE;
708 }
709
712 &FileBasic,
713 sizeof(FileBasic),
715 if (NT_SUCCESS(Status))
716 {
717 *dwFileAttributes = FileBasic.FileAttributes;
718 return TRUE;
719 }
720
722 return FALSE;
723}
DWORD dwFileAttributes
#define ERROR_INVALID_HANDLE
Definition: compat.h:98
@ FileBasicInformation
Definition: from_kernel.h:65
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

◆ GetFileAttributesExA()

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

Definition at line 619 of file fileinfo.c.

622{
623 PWCHAR FileNameW;
624
625 if (!(FileNameW = FilenameA2W(lpFileName, FALSE)))
626 return FALSE;
627
628 return GetFileAttributesExW(FileNameW, fInfoLevelId, lpFileInformation);
629}
BOOL WINAPI GetFileAttributesExW(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation)
Definition: fileinfo.c:552

◆ GetFileAttributesExW()

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

Definition at line 552 of file fileinfo.c.

555{
560 WIN32_FILE_ATTRIBUTE_DATA* FileAttributeData;
561
562 TRACE("GetFileAttributesExW(%S) called\n", lpFileName);
563
564
565 if (fInfoLevelId != GetFileExInfoStandard || lpFileInformation == NULL)
566 {
568 return FALSE;
569 }
570
571 /* Validate and translate the filename */
573 &FileName,
574 NULL,
575 NULL))
576 {
577 WARN ("Invalid path '%S'\n", lpFileName);
579 return FALSE;
580 }
581
582 /* build the object attributes */
584 &FileName,
586 NULL,
587 NULL);
588
589 /* Get file attributes */
592
594 if (!NT_SUCCESS (Status))
595 {
596 WARN ("NtQueryFullAttributesFile() failed (Status %lx)\n", Status);
598 return FALSE;
599 }
600
601 FileAttributeData = (WIN32_FILE_ATTRIBUTE_DATA*)lpFileInformation;
602 FileAttributeData->dwFileAttributes = FileInformation.FileAttributes;
603 FileAttributeData->ftCreationTime.dwLowDateTime = FileInformation.CreationTime.u.LowPart;
604 FileAttributeData->ftCreationTime.dwHighDateTime = FileInformation.CreationTime.u.HighPart;
605 FileAttributeData->ftLastAccessTime.dwLowDateTime = FileInformation.LastAccessTime.u.LowPart;
606 FileAttributeData->ftLastAccessTime.dwHighDateTime = FileInformation.LastAccessTime.u.HighPart;
607 FileAttributeData->ftLastWriteTime.dwLowDateTime = FileInformation.LastWriteTime.u.LowPart;
608 FileAttributeData->ftLastWriteTime.dwHighDateTime = FileInformation.LastWriteTime.u.HighPart;
609 FileAttributeData->nFileSizeLow = FileInformation.EndOfFile.u.LowPart;
610 FileAttributeData->nFileSizeHigh = FileInformation.EndOfFile.u.HighPart;
611
612 return TRUE;
613}
#define WARN(fmt,...)
Definition: debug.h:115
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
struct _FileName FileName
Definition: fatprocs.h:896
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
static OUT PIO_STATUS_BLOCK OUT PVOID FileInformation
Definition: pipe.c:75
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
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)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSTATUS NTAPI NtQueryFullAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_NETWORK_OPEN_INFORMATION FileInformation)
Definition: file.c:3990
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
@ GetFileExInfoStandard
Definition: winbase.h:1161
#define ERROR_BAD_PATHNAME
Definition: winerror.h:233

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

◆ GetFileAttributesW()

DWORD WINAPI GetFileAttributesW ( LPCWSTR  lpFileName)

Definition at line 652 of file fileinfo.c.

653{
658
659 /* Get the NT path name */
661 {
664 }
665
666 /* Prepare for querying attributes */
669 NULL, NULL);
670 /* Simply query attributes */
672 if (!NT_SUCCESS(Status))
673 {
674 /* It failed? Is it a DOS device? */
676 {
678 }
679
680 /* Set the error otherwise */
683 }
684
685 /* Return the file attributes */
686 return FileInformation.FileAttributes;
687}
NTSYSAPI ULONG NTAPI RtlIsDosDeviceName_U(_In_ PCWSTR Name)
#define FILE_ATTRIBUTE_ARCHIVE
Definition: nt_native.h:706
NTSTATUS NTAPI NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PFILE_BASIC_INFORMATION FileInformation)
Definition: file.c:3978
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106

Referenced by _tWinMain(), _waccess(), _wchmod(), _wmktemp(), _wsystem(), _wtmpnam(), ACTION_ResolveSource(), AddSubst(), cabinet_next_cabinet(), cache_QueryAssemblyInfo(), 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(), DllRegisterServer(), do_file_copyW(), BtrfsRecv::do_recv(), DoEntry(), DoWriteSoundEvents(), file_dlg_proc(), file_exists(), file_existsW(), file_get_Attributes(), FileExists(), FileExistsW(), FileMoniker_CreateFromDisplayName(), filesys_FileExists(), filesys_FolderExists(), filesys_GetFolder(), find_mono_dll(), find_published_source(), find_runtimes(), CFileDefExt::GeneralPageProc(), get_empty_cddrive(), get_fusion_filename(), get_unique_folder_name(), get_working_dir(), CSearchBar::GetAddressEditBoxPath(), CConfiguration::GetConfigurationFromFile(), GetFileAttributesA(), GetLongPathNameW(), GetShortPathNameW(), GetTempFileNameW(), GetVersionFromFileExW(), IAssemblyCacheImpl_InstallAssembly(), InstallSoftwareBusPnpEnumerator(), IntDeleteRecursive(), IntLoadKeyboardLayout(), LayoutList_ReadLayout(), LoadUserProfileW(), LocalScheduleJob(), MainWnd_OnInstall(), msi_create_temp_file(), msi_get_file_attributes(), MSI_GetComponentPath(), MSI_OpenPackageW(), MSI_OpenProductW(), NewActionDlg_OnOK(), CFileDefExt::OnFolderCustApply(), open_package(), parse_file_list(), PathFileExistsAndAttributesW(), PathFileExistsDefExtAndAttributesW(), PathFileExistsW(), PathIsDirectoryW(), PathIsSystemFolderW(), PathIsTemporaryW(), PathMakeSystemFolderW(), PathUnmakeSystemFolderW(), pendingRename(), PickIconDlg(), 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(), SHPathPrepareForWriteW(), START_TEST(), StartDocDlgW(), StartInstaller(), test_CopyFolder(), Test_DelNodeW(), test_file_link_information(), test_file_rename_information(), test_GetFile(), test_junction_points(), test_knownFolders(), test_LZOpenFileW(), test_NtCreateFile(), test_wshshell(), CDownloadManager::ThreadFunc(), WhereIsRecursiveDirOK(), XCOPY_DoCopy(), XCOPY_ProcessDestParm(), and XCOPY_ProcessSourceParm().

◆ GetFileInformationByHandle()

BOOL WINAPI GetFileInformationByHandle ( HANDLE  hFile,
LPBY_HANDLE_FILE_INFORMATION  lpFileInformation 
)

Definition at line 458 of file fileinfo.c.

460{
461 struct
462 {
463 FILE_FS_VOLUME_INFORMATION FileFsVolume;
464 WCHAR Name[255];
465 }
466 FileFsVolume;
467
468 FILE_BASIC_INFORMATION FileBasic;
469 FILE_INTERNAL_INFORMATION FileInternal;
470 FILE_STANDARD_INFORMATION FileStandard;
471 NTSTATUS errCode;
473
475 {
477 return FALSE;
478 }
479
482 &FileBasic,
485 if (!NT_SUCCESS(errCode))
486 {
487 BaseSetLastNTError(errCode);
488 return FALSE;
489 }
490
491 lpFileInformation->dwFileAttributes = (DWORD)FileBasic.FileAttributes;
492
493 lpFileInformation->ftCreationTime.dwHighDateTime = FileBasic.CreationTime.u.HighPart;
494 lpFileInformation->ftCreationTime.dwLowDateTime = FileBasic.CreationTime.u.LowPart;
495
496 lpFileInformation->ftLastAccessTime.dwHighDateTime = FileBasic.LastAccessTime.u.HighPart;
497 lpFileInformation->ftLastAccessTime.dwLowDateTime = FileBasic.LastAccessTime.u.LowPart;
498
499 lpFileInformation->ftLastWriteTime.dwHighDateTime = FileBasic.LastWriteTime.u.HighPart;
500 lpFileInformation->ftLastWriteTime.dwLowDateTime = FileBasic.LastWriteTime.u.LowPart;
501
504 &FileInternal,
507 if (!NT_SUCCESS(errCode))
508 {
509 BaseSetLastNTError(errCode);
510 return FALSE;
511 }
512
513 lpFileInformation->nFileIndexHigh = FileInternal.IndexNumber.u.HighPart;
514 lpFileInformation->nFileIndexLow = FileInternal.IndexNumber.u.LowPart;
515
518 &FileFsVolume,
519 sizeof(FileFsVolume),
521 if (!NT_SUCCESS(errCode))
522 {
523 BaseSetLastNTError(errCode);
524 return FALSE;
525 }
526
527 lpFileInformation->dwVolumeSerialNumber = FileFsVolume.FileFsVolume.VolumeSerialNumber;
528
531 &FileStandard,
534 if (!NT_SUCCESS(errCode))
535 {
536 BaseSetLastNTError(errCode);
537 return FALSE;
538 }
539
540 lpFileInformation->nNumberOfLinks = FileStandard.NumberOfLinks;
541 lpFileInformation->nFileSizeHigh = FileStandard.EndOfFile.u.HighPart;
542 lpFileInformation->nFileSizeLow = FileStandard.EndOfFile.u.LowPart;
543
544 return TRUE;
545}
@ FileInternalInformation
Definition: from_kernel.h:67
@ FileFsVolumeInformation
Definition: from_kernel.h:219
#define DWORD
Definition: nt_native.h:44
#define FileStandardInformation
Definition: propsheet.cpp:61
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
LARGE_INTEGER LastWriteTime
Definition: nt_native.h:941
LARGE_INTEGER CreationTime
Definition: nt_native.h:939
LARGE_INTEGER LastAccessTime
Definition: nt_native.h:940
__wchar_t WCHAR
Definition: xmlstorage.h:180

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(), ShellDirectory::read_directory(), WinDirectory::read_directory(), 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 331 of file fileinfo.c.

333{
334 NTSTATUS errCode;
335 FILE_STANDARD_INFORMATION FileStandard;
337
340 &FileStandard,
343 if (!NT_SUCCESS(errCode))
344 {
345 BaseSetLastNTError(errCode);
346 if ( lpFileSizeHigh == NULL )
347 {
348 return -1;
349 }
350 else
351 {
352 return 0;
353 }
354 }
355 if ( lpFileSizeHigh != NULL )
356 *lpFileSizeHigh = FileStandard.EndOfFile.u.HighPart;
357
358 return FileStandard.EndOfFile.u.LowPart;
359}

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(), D3DReadFileToBlob(), d3dx_include_from_file_open(), DECLARE_INTERFACE_(), DoImport(), DosCheckInput(), DosCreateFile(), DosCreateFileEx(), DosLoadDriver(), DosLoadExecutable(), DosOpenFile(), DoTypeFile(), EMF_GetEnhMetaFile(), CShellCommandSetValue::Execute(), ATL::CRegObject::file_register(), file_register(), FileAsyncReader_Length(), FileLockBytesImpl_Stat(), FileOpen(), get_estimated_size(), 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(), CJournaledTestList::LoadJournalFile(), LoadTextFileToEdit(), map_file(), map_fileW(), map_view_of_file(), MapAndLoad(), MapFile(), ATL::CAtlFileMappingBase::MapFile(), MapFileAndCheckSumA(), MapFileAndCheckSumW(), MemStreamFromFile(), 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(), SearchFile(), CHttpClient::SendFile(), sha_check(), StgOpenStorage(), test_CopyFile2(), test_CopyFileA(), test_FileMapping(), test_http_cache(), test_NtQuerySection(), test_overwrite(), test_ReadConsole(), test_ReplaceFileA(), testFileStore(), TLB_Mapping_Open(), VfdCheckImageFile(), VfdOpenImage(), WINTRUST_GetSignedMsgFromCatFile(), wmain(), and WriteJobShadowFile().

◆ GetFileSizeEx()

BOOL WINAPI GetFileSizeEx ( HANDLE  hFile,
PLARGE_INTEGER  lpFileSize 
)

Definition at line 367 of file fileinfo.c.

371{
372 NTSTATUS errCode;
373 FILE_STANDARD_INFORMATION FileStandard;
375
378 &FileStandard,
381 if (!NT_SUCCESS(errCode))
382 {
383 BaseSetLastNTError(errCode);
384 return FALSE;
385 }
386 if (lpFileSize)
387 *lpFileSize = FileStandard.EndOfFile;
388
389 return TRUE;
390}

◆ GetFileTime()

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

Definition at line 896 of file fileinfo.c.

900{
903 FILE_BASIC_INFORMATION FileBasic;
904
906 {
908 return FALSE;
909 }
910
913 &FileBasic,
916 if (!NT_SUCCESS(Status))
917 {
919 return FALSE;
920 }
921
922 if (lpCreationTime)
923 {
924 lpCreationTime->dwLowDateTime = FileBasic.CreationTime.LowPart;
925 lpCreationTime->dwHighDateTime = FileBasic.CreationTime.HighPart;
926 }
927
928 if (lpLastAccessTime)
929 {
930 lpLastAccessTime->dwLowDateTime = FileBasic.LastAccessTime.LowPart;
931 lpLastAccessTime->dwHighDateTime = FileBasic.LastAccessTime.HighPart;
932 }
933
934 if (lpLastWriteTime)
935 {
936 lpLastWriteTime->dwLowDateTime = FileBasic.LastWriteTime.LowPart;
937 lpLastWriteTime->dwHighDateTime = FileBasic.LastWriteTime.HighPart;
938 }
939
940 return TRUE;
941}
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
ULONG LowPart
Definition: typedefs.h:106

Referenced by AddKnownDriverToList(), copy(), DoReadAllOfFile(), DosInt21h(), File_RetrieveEncodedObjectW(), GetFileModifyTime(), CCabinet::GetFileTimes(), GetSetFileTimestamp(), LZCopy(), PROFILE_FlushFile(), PROFILE_Open(), ProtocolStream_Stat(), RecycleBin5File_RecycleBinFile_GetLastModificationTime(), replace(), 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 269 of file fileinfo.c.

270{
272 IO_STATUS_BLOCK StatusBlock;
274
275 /* Get real handle */
277
278 /* Check for console handle */
280 {
282 return FILE_TYPE_CHAR;
283 }
284
286 &StatusBlock,
287 &DeviceInfo,
290 if (!NT_SUCCESS(Status))
291 {
293 return FILE_TYPE_UNKNOWN;
294 }
295
296 switch (DeviceInfo.DeviceType)
297 {
302 case FILE_DEVICE_DFS:
303 case FILE_DEVICE_DISK:
306 return FILE_TYPE_DISK;
307
310 case FILE_DEVICE_NULL:
317 return FILE_TYPE_CHAR;
318
320 return FILE_TYPE_PIPE;
321 }
322
323 return FILE_TYPE_UNKNOWN;
324}
BOOL WINAPI DECLSPEC_HOTPATCH VerifyConsoleIoHandle(HANDLE hIoHandle)
Definition: console.c:1110
@ FileFsDeviceInformation
Definition: from_kernel.h:222
#define FILE_DEVICE_SERIAL_PORT
Definition: serial.c:44
#define FILE_DEVICE_DISK_FILE_SYSTEM
Definition: winioctl.h:114
#define FILE_DEVICE_NAMED_PIPE
Definition: winioctl.h:123
#define FILE_DEVICE_MOUSE
Definition: winioctl.h:121
#define FILE_DEVICE_NULL
Definition: winioctl.h:127
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:108
#define FILE_DEVICE_SCREEN
Definition: winioctl.h:134
#define FILE_DEVICE_DFS
Definition: winioctl.h:112
#define FILE_DEVICE_KEYBOARD
Definition: winioctl.h:117
#define FILE_DEVICE_DATALINK
Definition: winioctl.h:111
#define FILE_DEVICE_CD_ROM_FILE_SYSTEM
Definition: winioctl.h:109
#define FILE_DEVICE_MODEM
Definition: winioctl.h:149
#define FILE_DEVICE_PARALLEL_PORT
Definition: winioctl.h:128
#define FILE_DEVICE_CONTROLLER
Definition: winioctl.h:110
#define FILE_DEVICE_SOUND
Definition: winioctl.h:135
#define FILE_DEVICE_DISK
Definition: winioctl.h:113
#define FILE_DEVICE_PRINTER
Definition: winioctl.h:130
#define FILE_DEVICE_VIRTUAL_DISK
Definition: winioctl.h:142
#define FILE_TYPE_UNKNOWN
Definition: winbase.h:258
#define FILE_TYPE_CHAR
Definition: winbase.h:260
#define FILE_TYPE_PIPE
Definition: winbase.h:261
#define FILE_TYPE_DISK
Definition: winbase.h:259

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

◆ SetEndOfFile()

BOOL WINAPI SetEndOfFile ( HANDLE  hFile)

Definition at line 1004 of file fileinfo.c.

1005{
1007 FILE_END_OF_FILE_INFORMATION EndOfFileInfo;
1008 FILE_ALLOCATION_INFORMATION FileAllocationInfo;
1009 FILE_POSITION_INFORMATION FilePosInfo;
1011
1013 {
1015 return FALSE;
1016 }
1017
1018 //get current position
1020 hFile,
1022 &FilePosInfo,
1025 );
1026
1027 if (!NT_SUCCESS(Status)){
1029 return FALSE;
1030 }
1031
1032 EndOfFileInfo.EndOfFile.QuadPart = FilePosInfo.CurrentByteOffset.QuadPart;
1033
1034 /*
1035 NOTE:
1036 This call is not supposed to free up any space after the eof marker
1037 if the file gets truncated. We have to deallocate the space explicitly afterwards.
1038 But...most file systems dispatch both FileEndOfFileInformation
1039 and FileAllocationInformation as they were the same command.
1040
1041 */
1043 hFile,
1044 &IoStatusBlock, //out
1045 &EndOfFileInfo,
1048 );
1049
1050 if (!NT_SUCCESS(Status)){
1052 return FALSE;
1053 }
1054
1055 FileAllocationInfo.AllocationSize.QuadPart = FilePosInfo.CurrentByteOffset.QuadPart;
1056
1057
1059 hFile,
1060 &IoStatusBlock, //out
1061 &FileAllocationInfo,
1064 );
1065
1066 if (!NT_SUCCESS(Status)){
1068 return FALSE;
1069 }
1070
1071 return TRUE;
1072
1073}
@ FilePositionInformation
Definition: from_kernel.h:75
@ FileEndOfFileInformation
Definition: from_kernel.h:81
@ FileAllocationInformation
Definition: from_kernel.h:80
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:3096
LARGE_INTEGER AllocationSize
Definition: winternl.h:688
LARGE_INTEGER CurrentByteOffset
Definition: nt_native.h:955
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by _chsize_s(), _hwrite(), cache_container_set_size(), BtrfsRecv::cmd_clone(), BtrfsRecv::cmd_truncate(), create_file(), create_file_data(), create_test_dll(), DoSaveFile(), 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()

◆ SetFileAttributesByHandle()

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

Definition at line 730 of file fileinfo.c.

733{
734 FILE_BASIC_INFORMATION FileBasic;
737
739
741 {
743 return FALSE;
744 }
745
748 &FileBasic,
749 sizeof(FileBasic),
751 if (NT_SUCCESS(Status))
752 {
754
757 &FileBasic,
758 sizeof(FileBasic),
760 }
761
762 if (!NT_SUCCESS(Status))
763 {
765 return FALSE;
766 }
767
768 return TRUE;
769}

◆ SetFileAttributesW()

BOOL WINAPI SetFileAttributesW ( LPCWSTR  lpFileName,
DWORD  dwFileAttributes 
)

Definition at line 794 of file fileinfo.c.

796{
798 PWSTR PathUBuffer;
800 UNICODE_STRING NtPathU;
802 RTL_RELATIVE_NAME_U RelativeName;
805
806 /* Get relative name */
807 if (!RtlDosPathNameToRelativeNtPathName_U(lpFileName, &NtPathU, NULL, &RelativeName))
808 {
810 return FALSE;
811 }
812
813 /* Save buffer to allow later freeing */
814 PathUBuffer = NtPathU.Buffer;
815
816 /* If we have relative name (and root dir), use them instead */
817 if (RelativeName.RelativeName.Length != 0)
818 {
819 NtPathU.Length = RelativeName.RelativeName.Length;
820 NtPathU.MaximumLength = RelativeName.RelativeName.MaximumLength;
821 NtPathU.Buffer = RelativeName.RelativeName.Buffer;
822 }
823 else
824 {
825 RelativeName.ContainingDirectory = NULL;
826 }
827
828 /* Prepare the object attribute for opening the file */
831 RelativeName.ContainingDirectory, NULL);
832
833 /* Attempt to open the file, while supporting reparse point */
838 /* If opening failed, check whether it was because of reparse point support */
839 if (!NT_SUCCESS(Status))
840 {
841 /* Nope, just quit */
843 {
844 RtlReleaseRelativeName(&RelativeName);
845 RtlFreeHeap(RtlGetProcessHeap(), 0, PathUBuffer);
847
848 return FALSE;
849 }
850
851 /* Yes, retry without */
856 if (!NT_SUCCESS(Status))
857 {
858 RtlReleaseRelativeName(&RelativeName);
859 RtlFreeHeap(RtlGetProcessHeap(), 0, PathUBuffer);
861
862 return FALSE;
863 }
864 }
865
866 /* We don't need strings anylonger */
867 RtlReleaseRelativeName(&RelativeName);
868 RtlFreeHeap(RtlGetProcessHeap(), 0, PathUBuffer);
869
870 /* Zero our structure, we'll only set file attributes */
872 /* Set the attributes, filtering only allowed attributes, and forcing normal attribute */
874
875 /* Finally, set the attributes */
878 /* Close the file */
880
881 /* If it failed, set the error and fail */
882 if (!NT_SUCCESS(Status))
883 {
885
886 return FALSE;
887 }
888
889 return TRUE;
890}
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define FILE_OPEN_REPARSE_POINT
Definition: from_kernel.h:46
#define FILE_SYNCHRONOUS_IO_NONALERT
Definition: from_kernel.h:31
#define FILE_OPEN_FOR_BACKUP_INTENT
Definition: from_kernel.h:42
VOID NTAPI RtlReleaseRelativeName(_In_ PRTL_RELATIVE_NAME_U RelativeName)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToRelativeNtPathName_U(_In_ PCWSTR DosName, _Out_ PUNICODE_STRING NtName, _Out_ PCWSTR *PartName, _Out_ PRTL_RELATIVE_NAME_U RelativeName)
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:3952
#define FILE_ATTRIBUTE_VALID_SET_FLAGS
Definition: nt_native.h:715
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define SYNCHRONIZE
Definition: nt_native.h:61
#define FILE_SHARE_DELETE
Definition: nt_native.h:682
#define FILE_WRITE_ATTRIBUTES
Definition: nt_native.h:649
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
UNICODE_STRING RelativeName
Definition: rtltypes.h:1380
HANDLE ContainingDirectory
Definition: rtltypes.h:1381
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define ZeroMemory
Definition: winbase.h:1712

Referenced by _wchmod(), AddDelBackupEntryW(), BasepCopyFileExW(), ChangeAttributes(), BtrfsRecv::cmd_removexattr(), BtrfsRecv::cmd_rmdir(), BtrfsRecv::cmd_setxattr(), BtrfsRecv::cmd_truncate(), BtrfsRecv::cmd_unlink(), BtrfsRecv::cmd_write(), CreateStandardProfile(), CryptCATAdminAddCatalog(), delete_directory(), delete_file(), DELNODE_recurse_dirtree(), DllRegisterServer(), BtrfsRecv::do_recv(), file_put_Attributes(), CFileDefExt::GeneralPageProc(), InitializeSetupActionLog(), IntDeleteRecursive(), MoveFileWithProgressW(), MSI_OpenPackageW(), msi_set_file_attributes(), CFileDefExt::OnFolderCustApply(), PathMakeSystemFolderW(), PathUnmakeSystemFolderW(), RecursiveRemoveDir(), RecycleBin5_Create(), SdbUninstall(), SetFileAttributesA(), SetupInitializeFileLogW(), SHGetFolderPathAndSubDirW(), SHNotifyCopyFileW(), SHNotifyDeleteFileW(), SHNotifyMoveFileW(), SHNotifyRemoveDirectoryW(), START_TEST(), test_MultipleFiles(), test_NtCreateFile(), test_readonly(), test_ReplaceFileW(), XCOPY_DoCopy(), and TmpFile::~TmpFile().

◆ SetFilePointer()

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

Definition at line 54 of file fileinfo.c.

58{
59 FILE_POSITION_INFORMATION FilePosition;
60 FILE_STANDARD_INFORMATION FileStandard;
61 NTSTATUS errCode;
63 LARGE_INTEGER Distance;
64
65 TRACE("SetFilePointer(hFile %p, lDistanceToMove %d, dwMoveMethod %lu)\n",
66 hFile,lDistanceToMove,dwMoveMethod);
67
69 {
72 }
73
74 if (lpDistanceToMoveHigh)
75 {
76 Distance.u.HighPart = *lpDistanceToMoveHigh;
77 Distance.u.LowPart = lDistanceToMove;
78 }
79 else
80 {
81 Distance.QuadPart = lDistanceToMove;
82 }
83
84 switch(dwMoveMethod)
85 {
86 case FILE_CURRENT:
89 &FilePosition,
92 FilePosition.CurrentByteOffset.QuadPart += Distance.QuadPart;
93 if (!NT_SUCCESS(errCode))
94 {
95 if (lpDistanceToMoveHigh != NULL)
96 *lpDistanceToMoveHigh = -1;
97 BaseSetLastNTError(errCode);
99 }
100 break;
101 case FILE_END:
104 &FileStandard,
107 FilePosition.CurrentByteOffset.QuadPart =
108 FileStandard.EndOfFile.QuadPart + Distance.QuadPart;
109 if (!NT_SUCCESS(errCode))
110 {
111 if (lpDistanceToMoveHigh != NULL)
112 *lpDistanceToMoveHigh = -1;
113 BaseSetLastNTError(errCode);
115 }
116 break;
117 case FILE_BEGIN:
118 FilePosition.CurrentByteOffset.QuadPart = Distance.QuadPart;
119 break;
120 default:
123 }
124
125 if(FilePosition.CurrentByteOffset.QuadPart < 0)
126 {
129 }
130
131 if (lpDistanceToMoveHigh == NULL && FilePosition.CurrentByteOffset.HighPart != 0)
132 {
133 /* If we're moving the pointer outside of the 32 bit boundaries but
134 the application only passed a 32 bit value we need to bail out! */
137 }
138
139 errCode = NtSetInformationFile(hFile,
141 &FilePosition,
144 if (!NT_SUCCESS(errCode))
145 {
146 if (lpDistanceToMoveHigh != NULL)
147 *lpDistanceToMoveHigh = -1;
148
149 BaseSetLastNTError(errCode);
151 }
152
153 if (lpDistanceToMoveHigh != NULL)
154 {
155 *lpDistanceToMoveHigh = FilePosition.CurrentByteOffset.u.HighPart;
156 }
157
158 if (FilePosition.CurrentByteOffset.u.LowPart == MAXDWORD)
159 {
160 /* The value of -1 is valid here, especially when the new
161 file position is greater than 4 GB. Since NtSetInformationFile
162 succeeded we never set an error code and we explicitly need
163 to clear a previously set error code in this case, which
164 an application will check if INVALID_SET_FILE_POINTER is returned! */
166 }
167
168 return FilePosition.CurrentByteOffset.u.LowPart;
169}
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FILE_BEGIN
Definition: compat.h:761
#define INVALID_SET_FILE_POINTER
Definition: compat.h:732
#define MAXDWORD
#define FILE_END
Definition: winbase.h:114
#define FILE_CURRENT
Definition: winbase.h:113
#define ERROR_NEGATIVE_SEEK
Definition: winerror.h:203

◆ SetFilePointerEx()

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

Definition at line 177 of file fileinfo.c.

181{
184 FILE_POSITION_INFORMATION FilePosition;
185 FILE_STANDARD_INFORMATION FileStandard;
186
188 {
190 return FALSE;
191 }
192
193 switch (dwMoveMethod)
194 {
195 case FILE_CURRENT:
196 {
198 &FilePosition,
201 if (!NT_SUCCESS(Status))
202 {
204 return FALSE;
205 }
206
207 FilePosition.CurrentByteOffset.QuadPart += liDistanceToMove.QuadPart;
208 break;
209 }
210
211 case FILE_END:
212 {
214 &FileStandard,
217 if (!NT_SUCCESS(Status))
218 {
220 return FALSE;
221 }
222
223 FilePosition.CurrentByteOffset.QuadPart = FileStandard.EndOfFile.QuadPart +
224 liDistanceToMove.QuadPart;
225 break;
226 }
227
228 case FILE_BEGIN:
229 {
230 FilePosition.CurrentByteOffset.QuadPart = liDistanceToMove.QuadPart;
231 break;
232 }
233
234 default:
235 {
237 return FALSE;
238 }
239 }
240
241 if (FilePosition.CurrentByteOffset.QuadPart < 0)
242 {
244 return FALSE;
245 }
246
250 if (!NT_SUCCESS(Status))
251 {
253 return FALSE;
254 }
255
256 if (lpNewFilePointer != NULL)
257 {
258 *lpNewFilePointer = FilePosition.CurrentByteOffset;
259 }
260
261 return TRUE;
262}

Referenced by _chm_fetch_bytes(), BestFit_Write(), CryptSIPRetrieveSubjectGuid(), dump_memory64_info(), elf_map_file_read(), 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 948 of file fileinfo.c.

952{
955 FILE_BASIC_INFORMATION FileBasic;
956
958 {
960 return FALSE;
961 }
962
963 memset(&FileBasic, 0, sizeof(FILE_BASIC_INFORMATION));
964
965 if (lpCreationTime)
966 {
967 FileBasic.CreationTime.LowPart = lpCreationTime->dwLowDateTime;
968 FileBasic.CreationTime.HighPart = lpCreationTime->dwHighDateTime;
969 }
970
971 if (lpLastAccessTime)
972 {
973 FileBasic.LastAccessTime.LowPart = lpLastAccessTime->dwLowDateTime;
974 FileBasic.LastAccessTime.HighPart = lpLastAccessTime->dwHighDateTime;
975 }
976
977 if (lpLastWriteTime)
978 {
979 FileBasic.LastWriteTime.LowPart = lpLastWriteTime->dwLowDateTime;
980 FileBasic.LastWriteTime.HighPart = lpLastWriteTime->dwHighDateTime;
981 }
982
985 &FileBasic,
988 if (!NT_SUCCESS(Status))
989 {
991 return FALSE;
992 }
993
994 return TRUE;
995}
#define memset(x, y, z)
Definition: compat.h:39

Referenced by _futime(), cabinet_close_file_info(), copy(), DosInt21h(), CCabinet::ExtractFile(), CZipExtract::ExtractSingle(), 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 1081 of file fileinfo.c.

1085{
1087 FILE_VALID_DATA_LENGTH_INFORMATION ValidDataLengthInformation;
1089
1090 ValidDataLengthInformation.ValidDataLength.QuadPart = ValidDataLength;
1091
1093 hFile,
1094 &IoStatusBlock, //out
1095 &ValidDataLengthInformation,
1098 );
1099
1100 if (!NT_SUCCESS(Status)){
1102 return FALSE;
1103 }
1104
1105 return TRUE;
1106}
@ FileValidDataLengthInformation
Definition: from_kernel.h:100