UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FWindowsPlatformFile Class Reference

#include <WindowsPlatformFilePrivate.h>

+ Inheritance diagram for FWindowsPlatformFile:

Classes

class  FNormalizedDirectory
 
class  FNormalizedFilename
 

Public Member Functions

virtual bool FileExists (const TCHAR *Filename) override
 
virtual int64 FileSize (const TCHAR *Filename) override
 
virtual bool DeleteFile (const TCHAR *Filename) override
 
virtual bool IsReadOnly (const TCHAR *Filename) override
 
virtual bool MoveFile (const TCHAR *To, const TCHAR *From) override
 
virtual bool SetReadOnly (const TCHAR *Filename, bool bNewReadOnlyValue) override
 
virtual FDateTime GetTimeStamp (const TCHAR *Filename) override
 
virtual void SetTimeStamp (const TCHAR *Filename, FDateTime DateTime) override
 
virtual FDateTime GetAccessTimeStamp (const TCHAR *Filename) override
 
virtual FString GetFilenameOnDisk (const TCHAR *Filename) override
 
virtual ESymlinkResult IsSymlink (const TCHAR *Filename) override
 
virtual bool HasMarkOfTheWeb (FStringView Filename, FString *OutSourceURL=nullptr) override
 
virtual bool SetMarkOfTheWeb (FStringView Filename, bool bNewStatus, const FString *InSourceURL=nullptr) override
 
virtual FFileOpenResult OpenRead (const TCHAR *Filename, EOpenReadFlags Flags) override
 
virtual IFileHandleOpenRead (const TCHAR *Filename, bool bAllowWrite=false) override
 
virtual FFileOpenResult OpenReadNoBuffering (const TCHAR *Filename, EOpenReadFlags Flags) override
 
virtual IFileHandleOpenReadNoBuffering (const TCHAR *Filename, bool bAllowWrite=false) override
 
virtual IFileHandleOpenWrite (const TCHAR *Filename, bool bAppend=false, bool bAllowRead=false) override
 
virtual FOpenMappedResult OpenMappedEx (const TCHAR *Filename, EOpenReadFlags OpenOptions=EOpenReadFlags::None, int64 MaximumSize=0) override
 
virtual bool DirectoryExists (const TCHAR *Directory) override
 
virtual bool CreateDirectory (const TCHAR *Directory) override
 
virtual bool DeleteDirectory (const TCHAR *Directory) override
 
virtual FFileStatData GetStatData (const TCHAR *FilenameOrDirectory) override
 
virtual bool IterateDirectory (const TCHAR *Directory, FDirectoryVisitor &Visitor) override
 
virtual bool IterateDirectoryStat (const TCHAR *Directory, FDirectoryStatVisitor &Visitor) override
 
bool IterateDirectoryCommon (const TCHAR *Directory, const TFunctionRef< bool(const WIN32_FIND_DATAW &)> &Visitor)
 
virtual bool FileJournalIsAvailable (const TCHAR *VolumeOrPath=nullptr, ELogVerbosity::Type *OutErrorLevel=nullptr, FString *OutError=nullptr) override
 
virtual uint64 FileJournalGetMaximumSize (const TCHAR *VolumeOrPath, ELogVerbosity::Type *OutErrorLevel=nullptr, FString *OutError=nullptr) const override
 
virtual EFileJournalResult FileJournalGetLatestEntry (const TCHAR *VolumeName, FFileJournalId &OutJournalId, FFileJournalEntryHandle &OutEntryHandle, FString *OutError=nullptr) override
 
virtual bool FileJournalIterateDirectory (const TCHAR *Directory, FDirectoryJournalVisitorFunc Visitor, FString *OutError=nullptr) override
 
virtual FFileJournalData FileJournalGetFileData (const TCHAR *FilenameOrDirectory, FString *OutError=nullptr) override
 
virtual EFileJournalResult FileJournalReadModified (const TCHAR *VolumeName, const FFileJournalId &JournalIdOfStartingEntry, const FFileJournalEntryHandle &StartingJournalEntry, TMap< FFileJournalFileHandle, FString > &KnownDirectories, TSet< FString > &OutModifiedDirectories, FFileJournalEntryHandle &OutNextJournalEntry, FString *OutError=nullptr) override
 
virtual FString FileJournalGetVolumeName (FStringView InPath) override
 
- Public Member Functions inherited from IPhysicalPlatformFile
virtual bool ShouldBeUsed (IPlatformFile *Inner, const TCHAR *CmdLine) const override
 
virtual CORE_API bool Initialize (IPlatformFile *Inner, const TCHAR *CmdLine) override
 
virtual IPlatformFileGetLowerLevel () override
 
virtual void SetLowerLevel (IPlatformFile *NewLowerLevel) override
 
virtual const TCHARGetName () const override
 
- Public Member Functions inherited from IPlatformFile
CORE_API IPlatformFile ()
 
virtual CORE_API ~IPlatformFile ()
 
virtual void SetSandboxEnabled (bool bInEnabled)
 
virtual bool IsSandboxEnabled () const
 
virtual void InitializeAfterSetActive ()
 
virtual void InitializeAfterProjectFilePath ()
 
virtual void MakeUniquePakFilesForTheseFiles (const TArray< TArray< FString > > &InFiles)
 
virtual void InitializeNewAsyncIO ()
 
virtual void AddLocalDirectories (TArray< FString > &LocalDirectories)
 
virtual void BypassSecurity (bool bInBypass)
 
virtual void Tick ()
 
virtual bool DeleteFiles (const TArrayView< const TCHAR * > &Filenames)
 
virtual CORE_API FFileOpenResult OpenWrite (const TCHAR *Filename, EOpenWriteFlags Flags)
 
virtual CORE_API FFileOpenAsyncResult OpenAsyncRead (const TCHAR *Filename, EOpenReadFlags Flags)
 
virtual CORE_API IAsyncReadFileHandleOpenAsyncRead (const TCHAR *Filename, bool bAllowWrite=false)
 
virtual void SetAsyncMinimumPriority (EAsyncIOPriorityAndFlags MinPriority)
 
virtual CORE_API IMappedFileHandleOpenMapped (const TCHAR *Filename)
 
virtual CORE_API void GetTimeStampPair (const TCHAR *PathA, const TCHAR *PathB, FDateTime &OutTimeStampA, FDateTime &OutTimeStampB)
 
virtual CORE_API FDateTime GetTimeStampLocal (const TCHAR *Filename)
 
virtual CORE_API bool IterateDirectory (const TCHAR *Directory, FDirectoryVisitorFunc Visitor)
 
virtual CORE_API bool IterateDirectoryStat (const TCHAR *Directory, FDirectoryStatVisitorFunc Visitor)
 
virtual CORE_API bool IterateDirectoryRecursively (const TCHAR *Directory, FDirectoryVisitor &Visitor)
 
virtual CORE_API bool IterateDirectoryStatRecursively (const TCHAR *Directory, FDirectoryStatVisitor &Visitor)
 
virtual CORE_API bool IterateDirectoryRecursively (const TCHAR *Directory, FDirectoryVisitorFunc Visitor)
 
virtual CORE_API bool IterateDirectoryStatRecursively (const TCHAR *Directory, FDirectoryStatVisitorFunc Visitor)
 
virtual CORE_API void FindFiles (TArray< FString > &FoundFiles, const TCHAR *Directory, const TCHAR *FileExtension)
 
virtual CORE_API void FindFilesRecursively (TArray< FString > &FoundFiles, const TCHAR *Directory, const TCHAR *FileExtension)
 
virtual CORE_API bool DeleteDirectoryRecursively (const TCHAR *Directory)
 
virtual CORE_API bool CreateDirectoryTree (const TCHAR *Directory)
 
virtual CORE_API bool CopyFile (const TCHAR *To, const TCHAR *From, EPlatformFileRead ReadFlags=EPlatformFileRead::None, EPlatformFileWrite WriteFlags=EPlatformFileWrite::None)
 
virtual CORE_API bool CopyDirectoryTree (const TCHAR *DestinationDirectory, const TCHAR *Source, bool bOverwriteAllExisting)
 
virtual CORE_API FString ConvertToAbsolutePathForExternalAppForRead (const TCHAR *Filename)
 
virtual CORE_API FString ConvertToAbsolutePathForExternalAppForWrite (const TCHAR *Filename)
 
virtual bool SendMessageToServer (const TCHAR *Message, IFileServerMessageHandler *Handler)
 
virtual bool DoesCreatePublicFiles ()
 
virtual void SetCreatePublicFiles (bool bCreatePublicFiles)
 
virtual int64 GetAllowedBytesToWriteThrottledStorage (const TCHAR *DestinationPath=nullptr)
 

Static Public Member Functions

static void NormalizeWindowsPath (FStringBuilderBase &Path, bool bIsFilename)
 
static FORCENOINLINE HANDLE FindFirstFileWithWildcard (const TCHAR *Directory, WIN32_FIND_DATAW &OutData)
 
- Static Public Member Functions inherited from IPlatformFile
static CORE_API IPlatformFileGetPlatformPhysical ()
 
static CORE_API const TCHARGetPhysicalTypeName ()
 

Additional Inherited Members

- Public Types inherited from IPlatformFile
enum class  EOpenReadFlags : uint8 { None = 0 , AllowWrite = 1 << 0 , AllowDelete = 1 << 1 , NoBuffering = 1 << 2 }
 
enum class  EOpenWriteFlags : uint8 { None = 0 , AllowRead = 1 << 0 , Append = 1 << 1 }
 
typedef TFunctionRef< bool(const TCHAR *, bool)> FDirectoryVisitorFunc
 
typedef TFunctionRef< bool(const TCHAR *, const FFileStatData &)> FDirectoryStatVisitorFunc
 
typedef TFunctionRef< bool(const TCHAR *, const FFileJournalData &)> FDirectoryJournalVisitorFunc
 

Detailed Description

Windows File I/O implementation

Member Function Documentation

◆ CreateDirectory()

bool FWindowsPlatformFile::CreateDirectory ( const TCHAR Directory)
overridevirtual

Create a directory and return true if the directory was created or already existed.

Implements IPlatformFile.

◆ DeleteDirectory()

bool FWindowsPlatformFile::DeleteDirectory ( const TCHAR Directory)
overridevirtual

Delete a directory and return true if the directory was deleted or otherwise does not exist.

Implements IPlatformFile.

◆ DeleteFile()

bool FWindowsPlatformFile::DeleteFile ( const TCHAR Filename)
overridevirtual

Delete a file and return true if the file exists. Will not delete read only files.

Implements IPlatformFile.

◆ DirectoryExists()

bool FWindowsPlatformFile::DirectoryExists ( const TCHAR Directory)
overridevirtual

Return true if the directory exists.

Implements IPlatformFile.

◆ FileExists()

bool FWindowsPlatformFile::FileExists ( const TCHAR Filename)
overridevirtual

Return true if the file exists.

Implements IPlatformFile.

◆ FileJournalGetFileData()

FFileJournalData FWindowsPlatformFile::FileJournalGetFileData ( const TCHAR FilenameOrDirectory,
FString *  OutError = nullptr 
)
overridevirtual

Return the data for the given path as with GetStatData, but report a FFileJournalData instead, which notably includes the FFileJournalFileHandle for the file/directory. Check the FFileJournalData::bIsValid member before using the returned data

Reimplemented from IPlatformFile.

◆ FileJournalGetLatestEntry()

EFileJournalResult FWindowsPlatformFile::FileJournalGetLatestEntry ( const TCHAR VolumeName,
FFileJournalId OutJournalId,
FFileJournalEntryHandle OutEntryHandle,
FString *  OutError = nullptr 
)
overridevirtual

Report the current end of the journal for the given volume, to be used as the StartingJournalEntry in FileJournalGetModifiedDirectories. If !FileJournalIsAvaiable for the given volume, sets OutEntryHandle to FileJournalEntryHandleInvalid. Returns EFileJournalResult::Success if successful, otherwise an error code and optionally a user-displayable explanation for the error code.

Reimplemented from IPlatformFile.

◆ FileJournalGetMaximumSize()

uint64 FWindowsPlatformFile::FileJournalGetMaximumSize ( const TCHAR VolumeOrPath,
ELogVerbosity::Type OutErrorLevel = nullptr,
FString *  OutError = nullptr 
) const
overridevirtual

Return the maximum size of the FileJournal for the specified VolumeName, if available, zero otherwise. Optionally returns a user-displayable string for why the journal is not available and a severity level for the reason. VolumeName may be a VolumeName as returned by FileJournalGetVolumeName or any path to a file or directory on the Volume.

Reimplemented from IPlatformFile.

◆ FileJournalGetVolumeName()

FString FWindowsPlatformFile::FileJournalGetVolumeName ( FStringView  InPath)
overridevirtual

Return the VolumeSpecifier present in the given path. Returns empty string if path does not have a valid volume specifier for use by the FileJournal (e.g. some platforms do not support \paths for FileJournal).

See also
FPathViews::SplitVolumeSpecifier for a more general function that can return specifiers not usable by the FileJournal.

Reimplemented from IPlatformFile.

◆ FileJournalIsAvailable()

bool FWindowsPlatformFile::FileJournalIsAvailable ( const TCHAR VolumeOrPath = nullptr,
ELogVerbosity::Type OutErrorLevel = nullptr,
FString *  OutError = nullptr 
)
overridevirtual

Return whether FileJournal functionality is available on the current platform if VolumeName is nullptr or for the given Volume if VolumeName is non-null. Optionally returns a user-displayable string for why it is not available and a severity level for the reason. VolumeName may be a VolumeName as returned by FileJournalGetVolumeName or any path to a file or directory on the Volume.

Reimplemented from IPlatformFile.

◆ FileJournalIterateDirectory()

bool FWindowsPlatformFile::FileJournalIterateDirectory ( const TCHAR Directory,
FDirectoryJournalVisitorFunc  Visitor,
FString *  OutError = nullptr 
)
overridevirtual

Iterate the given directory as with IterateDirectoryStat, but report a FFileJournalData for each file and directory, which notably includes the FFileJournalFileHandle for the file/directory.

The paths returned as the first argument of the visitor function are the combined paths produced by combining the input directory with the relative path of the child file or directory.

If the FileJournal is unavailable on the current system the iteration will still succeed but the FFileJournalFileHandle for each child path will be set to FileJournalFileHandleInvalid.

If the FileJournal is available on the current system but not on the volume of the given directory, it is arbitrary whether the FFileJournalFileHandle will be validly set; if not valid they will be set to FileJournalFileHandleInvalid.

Returns
false if the directory did not exist or if the visitor returned false.

Reimplemented from IPlatformFile.

◆ FileJournalReadModified()

EFileJournalResult FWindowsPlatformFile::FileJournalReadModified ( const TCHAR VolumeName,
const FFileJournalId JournalIdOfStartingEntry,
const FFileJournalEntryHandle StartingJournalEntry,
TMap< FFileJournalFileHandle, FString > &  KnownDirectories,
TSet< FString > &  OutModifiedDirectories,
FFileJournalEntryHandle OutNextJournalEntry,
FString *  OutError = nullptr 
)
overridevirtual

Query the FileJournal to find a list of all directories on the given volume with files that have been added, deleted, or modified in the specified time range. The beginning of the time range is specified by JournalIdOfStartingEntry and StartingJournalEntry, which came from FileJournalGetLatestEntry or a previous call to FileJournalReadModified. The end of the range is the latest modification on the volume. VolumeName can be the return value from FileJournalGetVolumeName, or any path on the desired volume.

The caller must provide the mapping from FFileJournalFileHandle to DirectoryName; the FFileJournalFileHandle for each Directory can be found from FileJournalGetFileData or FileJournalIterateDirectory.

Modified directories are appended into OutModifiedDirectories, and the next FileJournal entry to scan is written into OutNextJournalEntry.

Returns EFileJournalResult::Success if successful, otherwise an error code and optionally a user-displayable explanation for the error code. In an error case, partial results may still be written into the output.

Reimplemented from IPlatformFile.

◆ FileSize()

int64 FWindowsPlatformFile::FileSize ( const TCHAR Filename)
overridevirtual

Return the size of the file, or -1 if it doesn't exist.

Implements IPlatformFile.

◆ FindFirstFileWithWildcard()

FORCENOINLINE HANDLE FWindowsPlatformFile::FindFirstFileWithWildcard ( const TCHAR Directory,
WIN32_FIND_DATAW OutData 
)
static

◆ GetAccessTimeStamp()

FDateTime FWindowsPlatformFile::GetAccessTimeStamp ( const TCHAR Filename)
overridevirtual

Return the last access time of a file. Returns FDateTime::MinValue() on failure

Implements IPlatformFile.

◆ GetFilenameOnDisk()

FString FWindowsPlatformFile::GetFilenameOnDisk ( const TCHAR Filename)
overridevirtual

For case insensitive filesystems, returns the full path of the file with the same case as in the filesystem

Implements IPlatformFile.

◆ GetStatData()

FFileStatData FWindowsPlatformFile::GetStatData ( const TCHAR FilenameOrDirectory)
overridevirtual

Return the stat data for the given file or directory. Check the FFileStatData::bIsValid member before using the returned data

Implements IPlatformFile.

◆ GetTimeStamp()

FDateTime FWindowsPlatformFile::GetTimeStamp ( const TCHAR Filename)
overridevirtual

Return the modification time of a file. Returns FDateTime::MinValue() on failure

Implements IPlatformFile.

◆ HasMarkOfTheWeb()

bool FWindowsPlatformFile::HasMarkOfTheWeb ( FStringView  Filename,
FString *  OutSourceURL = nullptr 
)
overridevirtual

Determine if the file has been downloaded from a web browser, based on platform-specific metadata.

Parameters
FilenameThe file to check if it has a mark of the web.
OutSourceURLAn optional pointer to return a source url if available.
Returns
true if the file has a mark of the web, false otherwise.
Remarks
Only works for files on disk and currently only implemented for Windows.

Reimplemented from IPlatformFile.

◆ IsReadOnly()

bool FWindowsPlatformFile::IsReadOnly ( const TCHAR Filename)
overridevirtual

Return true if the file is read only.

Implements IPlatformFile.

◆ IsSymlink()

ESymlinkResult FWindowsPlatformFile::IsSymlink ( const TCHAR Filename)
overridevirtual

Return true if the file is a symbolic link

Reimplemented from IPlatformFile.

◆ IterateDirectory()

bool FWindowsPlatformFile::IterateDirectory ( const TCHAR Directory,
FDirectoryVisitor Visitor 
)
overridevirtual

Call the Visit function of the visitor once for each file or directory in a single directory. This function does not explore subdirectories.

Parameters
DirectoryThe directory to iterate the contents of.
VisitorVisitor to call for each element of the directory
Returns
false if the directory did not exist or if the visitor returned false.

Implements IPlatformFile.

◆ IterateDirectoryCommon()

bool FWindowsPlatformFile::IterateDirectoryCommon ( const TCHAR Directory,
const TFunctionRef< bool(const WIN32_FIND_DATAW &)> &  Visitor 
)

◆ IterateDirectoryStat()

bool FWindowsPlatformFile::IterateDirectoryStat ( const TCHAR Directory,
FDirectoryStatVisitor Visitor 
)
overridevirtual

Call the Visit function of the visitor once for each file or directory in a single directory. This function does not explore subdirectories.

Parameters
DirectoryThe directory to iterate the contents of.
VisitorVisitor to call for each element of the directory
Returns
false if the directory did not exist or if the visitor returned false.

Implements IPlatformFile.

◆ MoveFile()

bool FWindowsPlatformFile::MoveFile ( const TCHAR To,
const TCHAR From 
)
overridevirtual

Attempt to move a file. Return true if successful. Will not overwrite existing files.

Implements IPlatformFile.

◆ NormalizeWindowsPath()

void FWindowsPlatformFile::NormalizeWindowsPath ( FStringBuilderBase Path,
bool  bIsFilename 
)
static

Convert from a valid Unreal Path to a canonical and strict-valid Windows Path. An Unreal Path may have either \ or / and may have empty directories (two / in a row), and may have .. and may be relative A canonical and strict-valid Windows Path has only \, does not have .., does not have empty directories, and is an absolute path, either \UNC or D:\ We need to use strict-valid Windows Paths when calling Windows API calls so that we can support the long-path prefix \?\

◆ OpenMappedEx()

FOpenMappedResult FWindowsPlatformFile::OpenMappedEx ( const TCHAR Filename,
EOpenReadFlags  OpenOptions = EOpenReadFlags::None,
int64  MaximumSize = 0 
)
overridevirtual

Open a file for async reading. This call does hit the disk; it is synchronous open.

Parameters
FilenameFile to be mapped. This doesn't actually map anything, just opens the file.
OpenOptionsAllows specifying map to be writable via AllowWrite or be ReadOnly by deafault.
Returns
Close the file by deleting the handle. A non-null return value does mean the file exists. Null can be returned for many reasons even if the file exists. Perhaps this platform does not support mapped files, or this file is compressed in a pak file. Generally you attempt to open mapped, and if that fails, then use other file operations instead.

Reimplemented from IPlatformFile.

◆ OpenRead() [1/2]

IFileHandle * FWindowsPlatformFile::OpenRead ( const TCHAR Filename,
bool  bAllowWrite = false 
)
overridevirtual

Attempt to open a file for reading. Please consider using the new overload that takes EReadFlags instead of bools as parameters.

Parameters
Filenamefile to be opened
bAllowWrite(applies to certain platforms only) whether this file is allowed to be written to by other processes. This flag is needed to open files that are currently being written to as well.
Returns
If successful will return a non-nullptr pointer. Close the file by deleting the handle.

Implements IPlatformFile.

◆ OpenRead() [2/2]

FFileOpenResult FWindowsPlatformFile::OpenRead ( const TCHAR Filename,
EOpenReadFlags  Flags 
)
overridevirtual

Open a file handle for reading.

Parameters
FilenameThe file to be opened
FlagsAllows specialization of the open operation,
See also
EOpenReadFlags
Returns
The return value will either contain the valid file handle or an error message.
See also
FFileOpenResult

Reimplemented from IPlatformFile.

◆ OpenReadNoBuffering() [1/2]

IFileHandle * FWindowsPlatformFile::OpenReadNoBuffering ( const TCHAR Filename,
bool  bAllowWrite = false 
)
overridevirtual

Reimplemented from IPlatformFile.

◆ OpenReadNoBuffering() [2/2]

FFileOpenResult FWindowsPlatformFile::OpenReadNoBuffering ( const TCHAR Filename,
EOpenReadFlags  Flags 
)
overridevirtual

Reimplemented from IPlatformFile.

◆ OpenWrite()

IFileHandle * FWindowsPlatformFile::OpenWrite ( const TCHAR Filename,
bool  bAppend = false,
bool  bAllowRead = false 
)
overridevirtual

Attempt to open a file for writing. If successful will return a non-nullptr pointer. Close the file by deleting the handle.

Implements IPlatformFile.

◆ SetMarkOfTheWeb()

bool FWindowsPlatformFile::SetMarkOfTheWeb ( FStringView  Filename,
bool  bNewStatus,
const FString *  InSourceURL = nullptr 
)
overridevirtual

Attempt to change the platform-specific metadata that indicates if the file has been downloaded from a web browser.

Parameters
FilenameThe file to change it's mark of the web status.
bNewStatusNew mark of the web status for the file.
InSourceURLAn optional pointer to a source url that will be applied if new status true.
Returns
true if the file's mark of the web status was successful changed, false otherwise.
Remarks
Only works for files on disk and currently only implemented for Windows.

Reimplemented from IPlatformFile.

◆ SetReadOnly()

bool FWindowsPlatformFile::SetReadOnly ( const TCHAR Filename,
bool  bNewReadOnlyValue 
)
overridevirtual

Attempt to change the read only status of a file. Return true if successful.

Implements IPlatformFile.

◆ SetTimeStamp()

void FWindowsPlatformFile::SetTimeStamp ( const TCHAR Filename,
FDateTime  DateTime 
)
overridevirtual

Sets the modification time of a file

Implements IPlatformFile.


The documentation for this class was generated from the following files: