rag
graphic 2d engine
Public Member Functions | Static Public Member Functions | Protected Attributes | Static Protected Attributes | List of all members
rag::File Class Reference

File multiplatform abstraction to read contents of a file. More...

#include <File.h>

Public Member Functions

 File (const std::string &path, bool bundle=true, bool logEnabled=true)
 Creates a File object. More...
 
bool open (std::string mode="rb", bool showErrors=true)
 Open the file.
 
void close ()
 Close the file.
 
size_t read (void *buffer, size_t count)
 Read into buffer the number of 'count' bytes.
 
long getSize ()
 Returns the size of the file.
 
size_t write (const void *ptr, size_t size, size_t count)
 Writes into the file.
 
bool exists ()
 Returns true if the file exists.
 
const std::string & getFullPath ()
 Returns the full path of the file, may contain bundle folder.
 

Static Public Member Functions

static std::string load (std::string filename, bool bundle=true, std::string mode="rb", bool showErrors=true)
 Convenient function to load files without deal with low level api.
 
static bool existsPath (const std::string &path)
 Returns true if the path exists.
 
static bool makePath (const std::string &path)
 Creates a folder.
 
static void clearPatchFiles ()
 Clean overrided files in bundle.
 
static void setPatchFile (const std::string &filename, const std::string &filepath)
 Override files in bundle.
 
static const std::map< std::string, std::string > & getPatchFiles ()
 Returns overrided files in bundle.
 

Protected Attributes

FILE * pFile
 
long size
 
std::string path
 
std::string osPath
 
bool bundle
 

Static Protected Attributes

static bool sPatchFilesLoaded
 
static std::map< std::string, std::string > patchFiles
 

Detailed Description

File multiplatform abstraction to read contents of a file.

Constructor & Destructor Documentation

File::File ( const std::string &  path,
bool  bundle = true,
bool  logEnabled = true 
)

Creates a File object.

Parameters
pathThe path where the file can be found.
bundleIf the file is inside the bundle. The bundle is the package created at build-time.
logEnabled

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