Ocular Engine
Ocular::Core::File Class Reference
Inheritance diagram for Ocular::Core::File:

Public Member Functions

 File (std::string const fullPath="")
void setPath (std::string const fullPath)
void refresh ()
bool exists () const
bool canRead () const
bool canWrite () const
bool isFile () const
bool isDirectory () const
bool isSymLink () const
bool isAbsolute () const
unsigned getSize () const
std::string getFullPath () const
std::string getName () const
std::string getExtension () const
std::string getDirectory () const
time_t getLastModifiedTime () const
void formatForSystem ()
virtual bool create (bool createDirectories=false)

Protected Attributes

bool m_IsReal
bool m_IsReadable
bool m_IsWritable
bool m_IsFile
bool m_IsDirectory
bool m_IsSymLink
bool m_IsAbsolute
unsigned m_FileSize
std::string m_FullPath
std::string m_Name
std::string m_Extension
std::string m_Directory

Constructor & Destructor Documentation

Ocular::Core::File::File ( std::string const  fullPath = "")

Providing an empty string sets the current path to that of the current working directory.

Member Function Documentation

bool Ocular::Core::File::canRead ( ) const

Returns whether the file at the specified path can be read from.

bool Ocular::Core::File::canWrite ( ) const

Returns whether the file at the specified path can be written to.

bool Ocular::Core::File::create ( bool  createDirectories = false)

Attempts to create the file if it does not already exist.

[in]createDirectoriesIf TRUE, creates all necessary parent directories that do not already exist.
bool TRUE if successful

Reimplemented in Ocular::Core::Directory.

bool Ocular::Core::File::exists ( ) const

Returns whether the object (file, directory, or symlink) at the specified path exists.

void Ocular::Core::File::formatForSystem ( )

Ensures that all path-separators are the same.

On Windows, the '\' separator is used.
On Linux-based systems, the '/' separator is used.

std::string Ocular::Core::File::getDirectory ( ) const

Returns the directory path of the file. Example:


Returns "/path/to/file"

std::string Ocular::Core::File::getExtension ( ) const

Returns the extension of the file. Example:


Returns ".txt"

std::string Ocular::Core::File::getFullPath ( ) const

Returns the full specified path of the file. Example:


Returns "/path/to/file/AFile.txt"

time_t Ocular::Core::File::getLastModifiedTime ( ) const

Returns the epoch time (in seconds) of the last write action to the file.

std::string Ocular::Core::File::getName ( ) const

Returns the name of the file. Example:


Returns "AFile"

unsigned Ocular::Core::File::getSize ( ) const

Returns the size of the file in bytes.

bool Ocular::Core::File::isAbsolute ( ) const

Returns whether the specified path is an absolute path.

bool Ocular::Core::File::isDirectory ( ) const

Returns whether the object at the specified path is a directory.

bool Ocular::Core::File::isFile ( ) const

Returns whether the object at the specified path is a file.

bool Ocular::Core::File::isSymLink ( ) const

Returns whether the object at the specified path is a symbolic link.

void Ocular::Core::File::refresh ( )

Refreshes all information about the file.

void Ocular::Core::File::setPath ( std::string const  fullPath)

Sets the path to the file object.

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