Tramway SDK
Public Member Functions | Public Attributes | List of all members
tram::FileReader Class Reference

#include <file.h>

Public Member Functions

 FileReader (const char *path, FileSource source=SOURCE_ANY)
 Loads a file into memory. More...
 
 ~FileReader ()
 Deletes the loaded file from memory. More...
 
bool is_open ()
 Checks if file was loaded into memory. More...
 

Public Attributes

const char * contents = nullptr
 
size_t length = 0
 

Constructor & Destructor Documentation

◆ FileReader()

tram::FileReader::FileReader ( const char *  path,
FileSource  source = SOURCE_ANY 
)

Loads a file into memory.

Use FileReader::is_open() to check if the file was successfully loaded. If it was, then you can access the contents through the FileReader::contents pointer and get the length of the file from FileReader::length.

Parameters
pathPath to the file.
sourceSource from which the file will be loaded.

◆ ~FileReader()

tram::FileReader::~FileReader ( )

Deletes the loaded file from memory.

This will free the memory pointed to by FileReader::contents, so if you need anything from there, you'll need to copy it out before you close the file.

Member Function Documentation

◆ is_open()

bool tram::FileReader::is_open ( )

Checks if file was loaded into memory.

Member Data Documentation

◆ contents

const char* tram::FileReader::contents = nullptr

◆ length

size_t tram::FileReader::length = 0

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