jaffarCommon
Loading...
Searching...
No Matches
Public Member Functions | List of all members
jaffarCommon::file::MemoryFileDirectory Class Reference

#include <file.hpp>

Public Member Functions

__JAFFAR_COMMON__INLINE__ MemoryFilefopen (const std::string filename, const std::string mode)
 
int fclose (MemoryFile *const file)
 
int fdestroy (const std::string &filename)
 
bool contains (const std::string &filename) const
 
int64_t getFileSize (const std::string &filename) const
 
uint8_t * getFileBuffer (const std::string &filename) const
 

Detailed Description

This class defines a directory on which files can be created, opened, closed and re-opened later. The file's lifetime is that of the directory itself, unless purposefully destroyed.

Member Function Documentation

◆ contains()

bool jaffarCommon::file::MemoryFileDirectory::contains ( const std::string &  filename) const
inline

Checks if the directory contains the given file

Parameters
[in]filenameThe name of the file to check for
Returns
True, if the file exists. False, otherwise.

◆ fclose()

int jaffarCommon::file::MemoryFileDirectory::fclose ( MemoryFile *const  file)
inline

Closes the provided file

Parameters
[in]fileThe file to close
Returns
Zero, if successful. Negative, if the file wasn't opened.

◆ fdestroy()

int jaffarCommon::file::MemoryFileDirectory::fdestroy ( const std::string &  filename)
inline

Forcibly destroys a file by name (similar to rm)

Parameters
filenameName of the file to delete from the directory
Returns
Zero, if successful. Negative if error.

◆ fopen()

__JAFFAR_COMMON__INLINE__ MemoryFile * jaffarCommon::file::MemoryFileDirectory::fopen ( const std::string  filename,
const std::string  mode 
)
inline

Opens a file The behaviour imitates that of the POSIX fopen, including mode. However, it also adds the size argument for the creation of new files. Appending mode is not supported as this assumes the buffer will increase, which is not currently possible for mem buffers

Parameters
[in]filenameThe file of the name to open
[in]modeThe opening mode (r,w,a,+)
Returns
The pointer to the new memory file, if successful. NULL, otherwise.

◆ getFileBuffer()

uint8_t * jaffarCommon::file::MemoryFileDirectory::getFileBuffer ( const std::string &  filename) const
inline

Retrieves a file's internal buffer

Parameters
[in]filenameThe name of the file to get the internal buffer from
Returns
A pointer to the file's internal buffer, if file is found; nullptr, otherwise.

◆ getFileSize()

int64_t jaffarCommon::file::MemoryFileDirectory::getFileSize ( const std::string &  filename) const
inline

Retrieves a file's size

Parameters
[in]filenameThe name of the file to check size for
Returns
The file size, if file is found; -1, otherwise.

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