Arma Reforger Script API
Loading...
Searching...
No Matches
SCR_FileIOHelper Interface Reference

Static Public Member Functions

static bool CreateDirectory (string absoluteDirectory)
 OBSOLETE - use FileIO.MakeDirectory instead
Create sub-directories in the proper order, circumventing a FileIO.MakeDirectory limitation.
 
static array< string > FindFiles (string directoryPath, string extension)
 
static bool Copy (string source, string destination, bool overwrite=true)
 Copy source file to destination.
 
static bool CopyFile (string sourceFile, string destinationFile)
 Copy source file to destination - creating the destination directory if needed.
 
static bool CopyDirectory (string sourceDirectory, string destinationDirectory)
 Recursively copy a directory to another, existing or not.
 
static bool RenameFile (string sourceFile, string destinationFile)
 Fake a renaming by copying then deleting the source file.
 
static string GetFileStringContent (string filePath, bool printWarning=true)
 Get file content as one big string.
 
static array< ref SCR_FileInfoGetDirectoryContent (string directory, string extension="")
 
static array< string > ReadFileContent (string filePath, bool printWarning=true)
 Get file content as array of lines.
 
static bool WriteFileContent (string filePath, notnull array< string > lines)
 Write all lines in the file, replacing all its content Overwrites the file if it exists.
 
static bool AppendFileContent (string filePath, notnull array< string > lines)
 Write all lines in the file after its existing content Adds to the file if it exists, creates it otherwise.
 
static bool IsValidFileName (string fileName)
 Get whether or not a file name is valid for the filesystem.
 
static string SanitiseFileName (string fileName)
 Sanitise the provided file name (removes invalid characters depending on the current OS, directory information, etc)
 

Protected Member Functions

void SCR_FileIOHelper ()
 

Static Protected Member Functions

static bool IsWindowsBased ()
 
static void FindFilesCallbackMethod (string fileName, FileAttribute attributes=0, string filesystem=string.Empty)
 

Static Protected Attributes

static const string PATH_DELIMITER = SCR_StringHelper.SLASH
 
static const string FORBIDDEN_FILENAME_CHARS_WINDOWS = "*/\<>:|?\t\r\n\""
 
static const string FORBIDDEN_FILENAME_CHARS_LINUX = SCR_StringHelper.SLASH
 
static const ref array< ref SCR_FileInfoFOUND_FILEINFOS = {}
 

Constructor & Destructor Documentation

◆ SCR_FileIOHelper()

void SCR_FileIOHelper.SCR_FileIOHelper ( )
protected

Member Function Documentation

◆ AppendFileContent()

static bool SCR_FileIOHelper.AppendFileContent ( string filePath,
notnull array< string > lines )
static

Write all lines in the file after its existing content Adds to the file if it exists, creates it otherwise.

Parameters
[in]filePathrelative or absolute
[in]lines
Returns
true on success, false otherwise

◆ Copy()

static bool SCR_FileIOHelper.Copy ( string source,
string destination,
bool overwrite = true )
static

Copy source file to destination.

Parameters
[in]sourcefile to copy
[in]destinationcopy destination
[in]overwriteset to false to prevent an accidental overwrite
Returns
true on success, false otherwise

◆ CopyDirectory()

static bool SCR_FileIOHelper.CopyDirectory ( string sourceDirectory,
string destinationDirectory )
static

Recursively copy a directory to another, existing or not.

Overwrite is allowed so check before copying

Parameters
[in]sourceDirectorycan be relative or absolute
[in]destinationDirectorycan be relative or absolute
Returns
true on success, false otherwise - it will (try to) copy all files, not halt on the first error

◆ CopyFile()

static bool SCR_FileIOHelper.CopyFile ( string sourceFile,
string destinationFile )
static

Copy source file to destination - creating the destination directory if needed.

Parameters
[in]sourceFile
[in]destinationFile
Returns
true on success, false otherwise

◆ CreateDirectory()

static bool SCR_FileIOHelper.CreateDirectory ( string absoluteDirectory)
static

OBSOLETE - use FileIO.MakeDirectory instead
Create sub-directories in the proper order, circumventing a FileIO.MakeDirectory limitation.

Parameters
[in]absoluteDirectorye.g C:/Arma4/Data/scripts/My/Sub/Directory
Returns
true if the whole directory structure was created or already exists, false otherwise

◆ FindFiles()

static array< string > SCR_FileIOHelper.FindFiles ( string directoryPath,
string extension )
static
Parameters
[in]directoryPath
[in]extension
Returns

◆ FindFilesCallbackMethod()

static void SCR_FileIOHelper.FindFilesCallbackMethod ( string fileName,
FileAttribute attributes = 0,
string filesystem = string::Empty )
staticprotected

◆ GetDirectoryContent()

static array< ref SCR_FileInfo > SCR_FileIOHelper.GetDirectoryContent ( string directory,
string extension = "" )
static
Parameters
[in]directorythe directory to browse
[in]extensionthe extension of files for which to look
Returns
array of file information or null on error

◆ GetFileStringContent()

static string SCR_FileIOHelper.GetFileStringContent ( string filePath,
bool printWarning = true )
static

Get file content as one big string.

Parameters
[in]filePathrelative or absolute
[in]printWarningtrue to print warning on issue, false otherwise
Returns
raw string file content or empty string if file does not exist or cannot be opened

◆ IsValidFileName()

static bool SCR_FileIOHelper.IsValidFileName ( string fileName)
static

Get whether or not a file name is valid for the filesystem.

Parameters
[in]fileNamethe file name to be sanitised - no file path accepted
Returns
true if the provided file name is valid under the current OS, false otherwise

◆ IsWindowsBased()

static bool SCR_FileIOHelper.IsWindowsBased ( )
staticprotected
Returns
true if Windows or Xbox, false otherwise

◆ ReadFileContent()

static array< string > SCR_FileIOHelper.ReadFileContent ( string filePath,
bool printWarning = true )
static

Get file content as array of lines.

Parameters
[in]filePathrelative or absolute
[in]printWarningtrue to print warning on issue, false otherwise
Returns
array of lines or null if file does not exist or cannot be opened

◆ RenameFile()

static bool SCR_FileIOHelper.RenameFile ( string sourceFile,
string destinationFile )
static

Fake a renaming by copying then deleting the source file.

Parameters
[in]sourceFile
[in]destinationFile
Returns
true on success, false on failure (no

◆ SanitiseFileName()

static string SCR_FileIOHelper.SanitiseFileName ( string fileName)
static

Sanitise the provided file name (removes invalid characters depending on the current OS, directory information, etc)

Parameters
[in]fileNamethe file name to be sanitised - can take a file path that will be stripped
Returns
the sanitised, trimmed file name or empty string if no characters are viable

◆ WriteFileContent()

static bool SCR_FileIOHelper.WriteFileContent ( string filePath,
notnull array< string > lines )
static

Write all lines in the file, replacing all its content Overwrites the file if it exists.

Parameters
[in]filePathrelative or absolute
[in]lines
Returns
true on success, false otherwise

Member Data Documentation

◆ FORBIDDEN_FILENAME_CHARS_LINUX

const string SCR_FileIOHelper.FORBIDDEN_FILENAME_CHARS_LINUX = SCR_StringHelper.SLASH
staticprotected

◆ FORBIDDEN_FILENAME_CHARS_WINDOWS

const string SCR_FileIOHelper.FORBIDDEN_FILENAME_CHARS_WINDOWS = "*/\<>:|?\t\r\n\""
staticprotected

◆ FOUND_FILEINFOS

const ref array<ref SCR_FileInfo> SCR_FileIOHelper.FOUND_FILEINFOS = {}
staticprotected

◆ PATH_DELIMITER

const string SCR_FileIOHelper.PATH_DELIMITER = SCR_StringHelper.SLASH
staticprotected

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