libultraship
Reimplementations of libultra (N64 SDK) functions for modern hardware
Loading...
Searching...
No Matches
Ship::FileHelper Class Reference

Utility class providing static helpers for reading and writing files on disk. More...

#include <FileHelper.h>

Static Public Member Functions

static bool Exists (const fs::path &filePath)
 Checks whether a file exists and is readable.
 
static std::vector< uint8_t > ReadAllBytes (const fs::path &filePath)
 Reads the entire contents of a file into a byte vector.
 
static std::string ReadAllText (const fs::path &filePath)
 Reads the entire contents of a file as a text string.
 
static std::vector< std::string > ReadAllLines (const fs::path &filePath)
 Reads a file and splits it into lines.
 
static void WriteAllBytes (const fs::path &filePath, const std::vector< uint8_t > &data)
 Writes a byte vector to a file, overwriting any existing content.
 
static void WriteAllBytes (const std::string &filePath, const std::vector< char > &data)
 Writes a char vector to a file, overwriting any existing content.
 
static void WriteAllBytes (const std::string &filePath, const char *data, int dataSize)
 Writes raw data to a file from a pointer and size, overwriting any existing content.
 
static void WriteAllText (const fs::path &filePath, const std::string &text)
 Writes a string to a file as text, overwriting any existing content.
 

Detailed Description

Utility class providing static helpers for reading and writing files on disk.

Similar to DiskFile but lives inside the Ship namespace. All methods are static and operate directly on filesystem paths.

Member Function Documentation

◆ Exists()

static bool Ship::FileHelper::Exists ( const fs::path &  filePath)
inlinestatic

Checks whether a file exists and is readable.

Parameters
filePathPath to the file to check.
Returns
true if the file can be opened for reading, false otherwise.

◆ ReadAllBytes()

static std::vector< uint8_t > Ship::FileHelper::ReadAllBytes ( const fs::path &  filePath)
inlinestatic

Reads the entire contents of a file into a byte vector.

Parameters
filePathPath to the file to read.
Returns
Vector containing every byte of the file, or an empty vector if the file cannot be opened.

◆ ReadAllLines()

static std::vector< std::string > Ship::FileHelper::ReadAllLines ( const fs::path &  filePath)
inlinestatic

Reads a file and splits it into lines.

Parameters
filePathPath to the file to read.
Returns
Vector of strings, one per line.

◆ ReadAllText()

static std::string Ship::FileHelper::ReadAllText ( const fs::path &  filePath)
inlinestatic

Reads the entire contents of a file as a text string.

Parameters
filePathPath to the file to read.
Returns
String containing the full file contents.

◆ WriteAllBytes() [1/3]

static void Ship::FileHelper::WriteAllBytes ( const fs::path &  filePath,
const std::vector< uint8_t > &  data 
)
inlinestatic

Writes a byte vector to a file, overwriting any existing content.

Note
Creates parent directories if they do not already exist.
Parameters
filePathPath to the file to write.
dataBytes to write.

◆ WriteAllBytes() [2/3]

static void Ship::FileHelper::WriteAllBytes ( const std::string &  filePath,
const char *  data,
int  dataSize 
)
inlinestatic

Writes raw data to a file from a pointer and size, overwriting any existing content.

Note
Creates parent directories if they do not already exist.
Parameters
filePathPath to the file to write.
dataPointer to the data to write.
dataSizeNumber of bytes to write.

◆ WriteAllBytes() [3/3]

static void Ship::FileHelper::WriteAllBytes ( const std::string &  filePath,
const std::vector< char > &  data 
)
inlinestatic

Writes a char vector to a file, overwriting any existing content.

Note
Creates parent directories if they do not already exist.
Parameters
filePathPath to the file to write.
dataCharacters to write.

◆ WriteAllText()

static void Ship::FileHelper::WriteAllText ( const fs::path &  filePath,
const std::string &  text 
)
inlinestatic

Writes a string to a file as text, overwriting any existing content.

Parameters
filePathPath to the file to write.
textString to write.

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