Deepsolver
|
The wrapper for file operations. More...
Public Member Functions | |
void | close () |
Closes previously opened file. | |
void | create (const std::string &fileName) |
Creates a new file in file system. | |
File () | |
The default constructor. | |
int | getFd () const |
Returns the handle of an opened file. | |
void | open (const std::string fileName) |
Opens existing file in read/write mode. | |
bool | opened () const |
Returns the opening state of this object. | |
void | openReadOnly (const std::string &fileName) |
Opens existing file in read-only mode. | |
size_t | read (void *buf, size_t bufSize) |
Reads data from an opened file. | |
void | readTextFile (StringVector &lines) |
Reads the file as a text file and saves lines in a string vector. | |
void | readTextFile (std::string &text) |
Reads the file as a text file and saves lines as one long string value. | |
size_t | write (const void *buf, size_t bufSize) |
Writes data to an opened file. | |
virtual | ~File () |
The destructor. | |
Static Public Member Functions | |
static std::string | baseName (const std::string &fileName) |
Returns the file name without parent directories. | |
static std::string | baseNameFromUrl (const std::string &url) |
Extracts the file name of a URL. | |
static bool | isDir (const std::string &fileName) |
Checks if the file is a directory. | |
static bool | isRegFile (const std::string &fileName) |
Checks if the file is a regular file. | |
static bool | isSymLink (const std::string &fileName) |
Checks if the file is a symlink. | |
static void | move (const std::string &oldFileName, const std::string &newFileName) |
Moves (renames) file inside of the same file system. | |
static void | readAhead (const std::string &fileName) |
Loads file content into file system cache. | |
static void | unlink (const std::string &fileName) |
Removes the file or remove the hard link. | |
Protected Attributes | |
int | m_fd |
This class simplifies the mostly popular operations with files. It is generally purposed to take care over the error code returned by system calls and throw SystemException if there are any problems.
std::string File::baseName | ( | const std::string & | fileName | ) | [static] |
[in] | The | file name to take base part from |
std::string File::baseNameFromUrl | ( | const std::string & | url | ) | [static] |
[in | url The URL value to extract file name from |
void Deepsolver::File::close | ( | ) |
This method closes previously opened file. If file is already closed or never be opened it is not an error, in this case nothing is done at all. This method is always called automatically on object destruction.
void File::create | ( | const std::string & | fileName | ) |
[in] | fileName | The name of the file to create |
int Deepsolver::File::getFd | ( | ) | const [inline] |
bool File::isDir | ( | const std::string & | fileName | ) | [static] |
[in] | fileName | The name of the file to check |
bool File::isRegFile | ( | const std::string & | fileName | ) | [static] |
[in] | fileName | The name of the file to check |
bool File::isSymLink | ( | const std::string & | fileName | ) | [static] |
[in] | fileName | The name of the file to check |
void File::move | ( | const std::string & | oldFileName, |
const std::string & | newFileName | ||
) | [static] |
[in | oldFileName The path to move file from | |
[in] | newFileName The path to move file to |
void Deepsolver::File::open | ( | const std::string | fileName | ) |
[in] | fileName | The name of the file to open |
bool Deepsolver::File::opened | ( | ) | const [inline] |
void File::openReadOnly | ( | const std::string & | fileName | ) |
[in] | fileName | The name of the file to open |
size_t Deepsolver::File::read | ( | void * | buf, |
size_t | bufSize | ||
) |
The length of the buffer is not limited. In case of providing the large buffer this method makes several reading attempts of smaller size. In addition this method takes care to be sure the operation is performed completely until entire requested data is read or error occurred.
[out] | buf | The buffer to save read data to |
[in] | bufSize | The size of the provided buffer |
void File::readAhead | ( | const std::string & | fileName | ) | [static] |
[in] | fileName | The path of the file to load data from |
void File::readTextFile | ( | StringVector & | lines | ) |
[out] | lines | The reference to a string vector to save lines to |
void File::readTextFile | ( | std::string & | text | ) |
[out] | text | The reference to a string object to save read data to |
void File::unlink | ( | const std::string & | fileName | ) | [static] |
[in] | fileName | The name of the file to remove hard link to |
size_t Deepsolver::File::write | ( | const void * | buf, |
size_t | bufSize | ||
) |
The length of the buffer is not limited. In case of providing the large buffer this method makes several writing attempts of smaller size. In addition this method takes care to be sure the operation is performed completely until entire requested data is written or error occurred.
[in] | buf | The buffer to write data from |
[in] | bufSize | The size of the provided buffer |