Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FFileHelper Struct Reference

#include <FileHelper.h>

Public Types

enum class  EHashOptions { None =0 , EnableVerify =1<<0 , ErrorMissingHash =1<<1 }
 
enum class  EEncodingOptions {
  AutoDetect , ForceAnsi , ForceUnicode , ForceUTF8 ,
  ForceUTF8WithoutBOM
}
 
enum class  EColorChannel {
  R , G , B , A ,
  All
}
 

Public Member Functions

enum UE_DEPRECATED (5.0, "EChannelMask has been deprecated in favor of EColorChannel") EChannelMask
 

Static Public Member Functions

static void BufferToString (FString &Result, const uint8 *Buffer, int32 Size)
 
static bool LoadFileToArray (TArray< uint8 > &Result, const TCHAR *Filename, uint32 Flags=0)
 
static bool LoadFileToArray (TArray64< uint8 > &Result, const TCHAR *Filename, uint32 Flags=0)
 
static bool LoadFileToString (FString &Result, FArchive &Reader, EHashOptions VerifyFlags=EHashOptions::None)
 
static bool LoadFileToString (FString &Result, const TCHAR *Filename, EHashOptions VerifyFlags=EHashOptions::None, uint32 ReadFlags=0)
 
static bool LoadFileToString (FString &Result, IPlatformFile *PlatformFile, const TCHAR *Filename, EHashOptions VerifyFlags=EHashOptions::None, uint32 ReadFlags=0)
 
static bool LoadFileToStringArray (TArray< FString > &Result, const TCHAR *Filename)
 
static bool LoadFileToStringArray (TArray< FString > &Result, const TCHAR *Filename, EHashOptions VerifyFlags)
 
static bool LoadFileToStringArrayWithPredicate (TArray< FString > &Result, const TCHAR *Filename, TFunctionRef< bool(const FString &)> Predicate)
 
static bool LoadFileToStringArrayWithPredicate (TArray< FString > &Result, const TCHAR *Filename, TFunctionRef< bool(const FString &)> Predicate, EHashOptions VerifyFlags)
 
static bool LoadFileToStringWithLineVisitor (const TCHAR *Filename, TFunctionRef< void(FStringView Line)> Visitor)
 
static bool SaveArrayToFile (TArrayView< const uint8 > Array, const TCHAR *Filename, IFileManager *FileManager=&IFileManager::Get(), uint32 WriteFlags=0)
 
static bool SaveArrayToFile (const TArray64< uint8 > &Array, const TCHAR *Filename, IFileManager *FileManager=&IFileManager::Get(), uint32 WriteFlags=0)
 
static bool SaveStringToFile (FStringView String, const TCHAR *Filename, EEncodingOptions EncodingOptions=EEncodingOptions::AutoDetect, IFileManager *FileManager=&IFileManager::Get(), uint32 WriteFlags=0)
 
static bool SaveStringArrayToFile (const TArray< FString > &Lines, const TCHAR *Filename, EEncodingOptions EncodingOptions=EEncodingOptions::AutoDetect, IFileManager *FileManager=&IFileManager::Get(), uint32 WriteFlags=0)
 
static bool CreateBitmap (const TCHAR *Pattern, int32 DataWidth, int32 DataHeight, const struct FColor *Data, FIntRect *SubRectangle=NULL, IFileManager *FileManager=&IFileManager::Get(), FString *OutFilename=NULL, bool bInWriteAlpha=false, EColorChannel ColorChannel=EColorChannel::All)
 
static bool GenerateNextBitmapFilename (const FString &Pattern, const FString &Extension, FString &OutFilename, IFileManager *FileManager=&IFileManager::Get())
 
static void GenerateDateTimeBasedBitmapFilename (const FString &Pattern, const FString &Extension, FString &OutFilename)
 
static bool LoadANSITextFileToStrings (const TCHAR *InFilename, IFileManager *InFileManager, TArray< FString > &OutStrings)
 
static bool IsFilenameValidForSaving (const FString &Filename, FText &OutError)
 
static PRAGMA_DISABLE_DEPRECATION_WARNINGS bool CreateBitmap (const TCHAR *Pattern, int32 DataWidth, int32 DataHeight, const struct FColor *Data, FIntRect *SubRectangle, IFileManager *FileManager, FString *OutFilename, bool bInWriteAlpha, EChannelMask ChannelMask)
 

Detailed Description

Definition at line 27 of file FileHelper.h.

Member Enumeration Documentation

◆ EColorChannel

Enumerator
All 

Definition at line 47 of file FileHelper.h.

◆ EEncodingOptions

Enumerator
AutoDetect 
ForceAnsi 
ForceUnicode 
ForceUTF8 
ForceUTF8WithoutBOM 

Definition at line 38 of file FileHelper.h.

◆ EHashOptions

Enumerator
None 
EnableVerify 

Enable the async task for verifying the hash for the file being loaded

ErrorMissingHash 

A missing hash entry should trigger an error

Definition at line 29 of file FileHelper.h.

Member Function Documentation

◆ BufferToString()

static void FFileHelper::BufferToString ( FString & Result,
const uint8 * Buffer,
int32 Size )
static

Load a text file to an FString. Supports all combination of ANSI/Unicode files and platforms.

◆ CreateBitmap() [1/2]

static PRAGMA_DISABLE_DEPRECATION_WARNINGS bool FFileHelper::CreateBitmap ( const TCHAR * Pattern,
int32 DataWidth,
int32 DataHeight,
const struct FColor * Data,
FIntRect * SubRectangle,
IFileManager * FileManager,
FString * OutFilename,
bool bInWriteAlpha,
EChannelMask ChannelMask )
static

◆ CreateBitmap() [2/2]

static bool FFileHelper::CreateBitmap ( const TCHAR * Pattern,
int32 DataWidth,
int32 DataHeight,
const struct FColor * Data,
FIntRect * SubRectangle = NULL,
IFileManager * FileManager = &IFileManager::Get(),
FString * OutFilename = NULL,
bool bInWriteAlpha = false,
EColorChannel ColorChannel = EColorChannel::All )
static

Saves a 24/32Bit BMP file to disk for debug image dump purposes

for general image saving (to BMP or any other format); use FImageUtils::SaveImage instead CreateBitmap is mainly for debug dump images

note this also calls SendDataToPCViaUnrealConsole and uses GenerateNextBitmapFilename if Pattern does not have ".bmp" on it

Parameters
Patternfilename with path, must not be 0, if with "bmp" extension (e.g. "out.bmp") the filename stays like this, if without (e.g. "out") automatic index numbers are addended (e.g. "out00002.bmp")
DataWidth- Width of the bitmap supplied in Data >0
DataHeight- Height of the bitmap supplied in Data >0
Datamust not be 0
SubRectangleoptional, specifies a sub-rectangle of the source image to save out. If NULL, the whole bitmap is saved
FileManagermust not be 0
OutFilenameoptional, if specified filename will be output
bInWriteAlphaoptional, specifies whether to write out the alpha channel. Will force BMP V4 format.
ColorChanneloptional, specifies a specific channel to write out (will be written out to all channels gray scale).
Returns
true if success

◆ GenerateDateTimeBasedBitmapFilename()

static void FFileHelper::GenerateDateTimeBasedBitmapFilename ( const FString & Pattern,
const FString & Extension,
FString & OutFilename )
static

Generates the next unique bitmap filename with a specified extension

Parameters
PatternFilename with path, but without extension.
ExtensionFile extension to be appended
OutFilenameReference to an FString where the newly generated filename will be placed
Returns
true if success

◆ GenerateNextBitmapFilename()

static bool FFileHelper::GenerateNextBitmapFilename ( const FString & Pattern,
const FString & Extension,
FString & OutFilename,
IFileManager * FileManager = &IFileManager::Get() )
static

Generates the next unique bitmap filename with a specified extension

Parameters
PatternFilename with path, but without extension.
ExtensionFile extension to be appended
OutFilenameReference to an FString where the newly generated filename will be placed
FileManagerReference to a IFileManager (or the global instance by default)
Returns
true if success

◆ IsFilenameValidForSaving()

static bool FFileHelper::IsFilenameValidForSaving ( const FString & Filename,
FText & OutError )
static

Checks to see if a filename is valid for saving. A filename must be under FPlatformMisc::GetMaxPathLength() to be saved

Parameters
FilenameFilename, with or without path information, to check.
OutErrorIf an error occurs, this is the reason why

◆ LoadANSITextFileToStrings()

static bool FFileHelper::LoadANSITextFileToStrings ( const TCHAR * InFilename,
IFileManager * InFileManager,
TArray< FString > & OutStrings )
static

Load the given ANSI text file to an array of strings - one FString per line of the file. Intended for use in simple text parsing actions

Parameters
InFilenameThe text file to read, full path
InFileManagerThe filemanager to use - NULL will use &IFileManager::Get()
OutStringsThe array of FStrings to fill in
Returns
bool true if successful, false if not

◆ LoadFileToArray() [1/2]

static bool FFileHelper::LoadFileToArray ( TArray64< uint8 > & Result,
const TCHAR * Filename,
uint32 Flags = 0 )
static

Load a binary file to a dynamic array with two uninitialized bytes at end as padding.

Parameters
ResultReceives the contents of the file
FilenameThe file to read
FlagsFlags to pass to IFileManager::CreateFileReader

◆ LoadFileToArray() [2/2]

static bool FFileHelper::LoadFileToArray ( TArray< uint8 > & Result,
const TCHAR * Filename,
uint32 Flags = 0 )
static

Load a binary file to a dynamic array with two uninitialized bytes at end as padding.

Parameters
ResultReceives the contents of the file
FilenameThe file to read
FlagsFlags to pass to IFileManager::CreateFileReader

◆ LoadFileToString() [1/3]

static bool FFileHelper::LoadFileToString ( FString & Result,
const TCHAR * Filename,
EHashOptions VerifyFlags = EHashOptions::None,
uint32 ReadFlags = 0 )
static

Load a text file to an FString. Supports all combination of ANSI/Unicode files and platforms.

Parameters
ResultString representation of the loaded file
FilenameName of the file to load
VerifyFlagsFlags controlling the hash verification behavior ( see EHashOptions )

◆ LoadFileToString() [2/3]

static bool FFileHelper::LoadFileToString ( FString & Result,
FArchive & Reader,
EHashOptions VerifyFlags = EHashOptions::None )
static

Load a text file to an FString. Supports all combination of ANSI/Unicode files and platforms.

Parameters
ResultString representation of the loaded file
ArchiveName of the archive to load from
VerifyFlagsFlags controlling the hash verification behavior ( see EHashOptions )

◆ LoadFileToString() [3/3]

static bool FFileHelper::LoadFileToString ( FString & Result,
IPlatformFile * PlatformFile,
const TCHAR * Filename,
EHashOptions VerifyFlags = EHashOptions::None,
uint32 ReadFlags = 0 )
static

Load a text file to an FString. Supports all combination of ANSI/Unicode files and platforms.

Parameters
ResultString representation of the loaded file
PlatformFilePlatformFile interface to use
FilenameName of the file to load
VerifyFlagsFlags controlling the hash verification behavior ( see EHashOptions )

◆ LoadFileToStringArray() [1/2]

static bool FFileHelper::LoadFileToStringArray ( TArray< FString > & Result,
const TCHAR * Filename )
static

Load a text file to an array of strings. Supports all combination of ANSI/Unicode files and platforms.

Parameters
ResultString representation of the loaded file
FilenameName of the file to load

◆ LoadFileToStringArray() [2/2]

static bool FFileHelper::LoadFileToStringArray ( TArray< FString > & Result,
const TCHAR * Filename,
EHashOptions VerifyFlags )
static

◆ LoadFileToStringArrayWithPredicate() [1/2]

static bool FFileHelper::LoadFileToStringArrayWithPredicate ( TArray< FString > & Result,
const TCHAR * Filename,
TFunctionRef< bool(const FString &)> Predicate )
static

Load a text file to an array of strings, filtered by a user-defined predicate. Supports all combination of ANSI/Unicode files and platforms.

Parameters
ResultString representation of the loaded file
FilenameName of the file to load
PredicateCondition for whether or not to add the line to the array

◆ LoadFileToStringArrayWithPredicate() [2/2]

static bool FFileHelper::LoadFileToStringArrayWithPredicate ( TArray< FString > & Result,
const TCHAR * Filename,
TFunctionRef< bool(const FString &)> Predicate,
EHashOptions VerifyFlags )
static

◆ LoadFileToStringWithLineVisitor()

static bool FFileHelper::LoadFileToStringWithLineVisitor ( const TCHAR * Filename,
TFunctionRef< void(FStringView Line)> Visitor )
static

Load a text file and invoke a visitor for each line. Supports all combination of ANSI/Unicode files and platforms.

Parameters
FilenameName of the file to load
VisitorVisitor to invoke for each non-empty line in the file

◆ SaveArrayToFile() [1/2]

static bool FFileHelper::SaveArrayToFile ( const TArray64< uint8 > & Array,
const TCHAR * Filename,
IFileManager * FileManager = &IFileManager::Get(),
uint32 WriteFlags = 0 )
static

Save a binary array to a file.

◆ SaveArrayToFile() [2/2]

static bool FFileHelper::SaveArrayToFile ( TArrayView< const uint8 > Array,
const TCHAR * Filename,
IFileManager * FileManager = &IFileManager::Get(),
uint32 WriteFlags = 0 )
static

Save a binary array to a file.

◆ SaveStringArrayToFile()

static bool FFileHelper::SaveStringArrayToFile ( const TArray< FString > & Lines,
const TCHAR * Filename,
EEncodingOptions EncodingOptions = EEncodingOptions::AutoDetect,
IFileManager * FileManager = &IFileManager::Get(),
uint32 WriteFlags = 0 )
static

Write the FString to a file. Supports all combination of ANSI/Unicode files and platforms.

◆ SaveStringToFile()

static bool FFileHelper::SaveStringToFile ( FStringView String,
const TCHAR * Filename,
EEncodingOptions EncodingOptions = EEncodingOptions::AutoDetect,
IFileManager * FileManager = &IFileManager::Get(),
uint32 WriteFlags = 0 )
static

Write the FString to a file. Supports all combination of ANSI/Unicode files and platforms.

◆ UE_DEPRECATED()

enum FFileHelper::UE_DEPRECATED ( 5. 0,
"EChannelMask has been deprecated in favor of EColorChannel"  )
inlinestrong

Definition at line 226 of file FileHelper.h.


The documentation for this struct was generated from the following file: