FileUtilities Class Reference

#include <file_utilities.h>

Static Public Member Functions

static MAXON_METHOD Result< void > ReadFileToMemory (UrlOrInputStream &&name, WritableArrayInterface< Char > &arr)
 
static MAXON_METHOD Result< void > ReadUtfFile (UrlOrInputStream &&url, WritableArrayInterface< Utf32Char > &arr, UTFTEXT_OPTIONS::TEXTENCODING defaultDecoding=UTFTEXT_OPTIONS::TEXTENCODING::UTF8)
 
static MAXON_METHOD Result< void > WriteUtfFile (const Url &url, const ArrayInterface< Utf32Char > &arr, UTFTEXT_OPTIONS::TEXTENCODING encoding=UTFTEXT_OPTIONS::TEXTENCODING::UTF8, Bool dontWriteHeader=false)
 
static MAXON_METHOD Result< void > CompareFiles (UrlOrInputStream &&file1, UrlOrInputStream &&file2)
 
template<typename T >
static Result< void > ReadToArray (UrlOrInputStream &&url, BaseArray< T > &dest)
 
static MAXON_METHOD Result< void > CopyStream (const InputStreamRef &from, const OutputStreamRef &to)
 
static MAXON_METHOD Result< void > CopyFileOrDirectory (const Url &from, const Url &to)
 
static MAXON_METHOD Result< void > CopyFileOrDirectory (const Url &from, const String &to, const WriteArchiveRef &archive)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (FileUtilities, MAXON_REFERENCE_NONE, "net.maxon.interface.fileutilities")
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( FileUtilities  ,
MAXON_REFERENCE_NONE  ,
"net.maxon.interface.fileutilities"   
)
private

◆ ReadFileToMemory()

static MAXON_METHOD Result<void> ReadFileToMemory ( UrlOrInputStream &&  name,
WritableArrayInterface< Char > &  arr 
)
static

Reads a file into memory.

Parameters
[in]nameName or Stream of the file.
[out]arrArray holding the memory, will be initialized inside.
Returns
OK on success.

◆ ReadUtfFile()

static MAXON_METHOD Result<void> ReadUtfFile ( UrlOrInputStream &&  url,
WritableArrayInterface< Utf32Char > &  arr,
UTFTEXT_OPTIONS::TEXTENCODING  defaultDecoding = UTFTEXT_OPTIONS::TEXTENCODING::UTF8 
)
static

Reads a file into memory. If an UTF encoding is detected the proper decoding takes place.

Parameters
[in]urlName or Stream of the file.
[out]arrArray holding the memory, will be initialized inside.
[in]defaultDecodingThe character decoding that will be used if the file does not contain any Byte Order Mark (BOM).
Returns
OK on success.

◆ WriteUtfFile()

static MAXON_METHOD Result<void> WriteUtfFile ( const Url url,
const ArrayInterface< Utf32Char > &  arr,
UTFTEXT_OPTIONS::TEXTENCODING  encoding = UTFTEXT_OPTIONS::TEXTENCODING::UTF8,
Bool  dontWriteHeader = false 
)
static

Writes a Utf32Char array from memory to disc in a UTF-encoded format.

Parameters
[in]urlThe file to be written.
[in]arrArray holding the data.
[in]encodingThe character encoding to be used.
[in]dontWriteHeaderIf true the utf8 header will not be written.
Returns
OK on success.

◆ CompareFiles()

static MAXON_METHOD Result<void> CompareFiles ( UrlOrInputStream &&  file1,
UrlOrInputStream &&  file2 
)
static

Compares the content of 2 files for binary equality.

Parameters
[in]file1Name or Stream of the file 1.
[in]file2Name or Stream of the file 2.
Returns
Success and result of the comparison. If the files don't match or cannot be read an error is returned.

◆ ReadToArray()

Result< void > ReadToArray ( UrlOrInputStream &&  url,
BaseArray< T > &  dest 
)
static

Reads stream directly into an array

Parameters
[in]urlpath to stream
[out]destBaseArray where the data is stored

◆ CopyStream()

static MAXON_METHOD Result<void> CopyStream ( const InputStreamRef &  from,
const OutputStreamRef &  to 
)
static

Copies all bytes from #from to #to. This function reads bytes as long as possible. It doesn't call the Close() method on #from or #to.

Parameters
[in]fromThe stream from which the bytes shall be read.
[in]toThe stream to which the bytes shall be written.
Returns
Success of operation.

◆ CopyFileOrDirectory() [1/2]

static MAXON_METHOD Result<void> CopyFileOrDirectory ( const Url from,
const Url to 
)
static

Copies the file or directory #from to #to. If it doesn't already exist, a file or directory is created for the Url #to. For a file its content is copied, for a directory a recursive copy happens. Symbolic links are skipped.

Parameters
[in]fromThe source Url.
[in]toThe destination Url.
Returns
Success of operation.

◆ CopyFileOrDirectory() [2/2]

static MAXON_METHOD Result<void> CopyFileOrDirectory ( const Url from,
const String to,
const WriteArchiveRef &  archive 
)
static

Copies the file or directory #from into an archive #archive/#to. If it doesn't already exist, a file or directory is created for the Url #to. For a file its content is copied, for a directory a recursive copy happens. Symbolic links are skipped.

Parameters
[in]fromThe source Url.
[in]toThe relative destination Url in the archive.
[in]archiveArchive to write to.
Returns
Success of operation.