Utility wrapper for file objects.
More...
#include <xmog_util_file.h>
|
| file (const char *name_) |
|
| file (const std::string &name_) |
|
| file (const file &parent_, const char *const name_) |
|
| operator const std::string & () const |
| Convert the file instance to a string representing its file name.
|
|
bool | operator== (const std::string &name) const |
|
const char * | name () const |
| Return the file's name.
|
|
const char * | key_name () const |
| Return the file's name.
|
|
file | nested (const char *sub) const |
| Return the file object representing a nested file, relative to this file.
|
|
bool | exists () const |
| Return true if this instance represents an existing file.
|
|
off_t | size () const |
| Return the number of bytes in the file.
|
|
bool | is_dir () const |
| Return true if this instance represents a directory.
|
|
bool | is_file () const |
| Return true if this instance represents a regular file.
|
|
size_t | list (::std::vector< file > &container, const char *filter=NULL, file_spec fs=fileAndDir, bool bRecurse=false, const char *terms[]=noTerminators) const |
| Accumulate a list of nested files in accordance with the specified criteria. More...
|
|
std::string | path (const char *filter, file_spec fs=onlyFile) const |
| Accumulate a path of nested files in accordance with the specified criteria. More...
|
|
int | read (char **pdata, jint *length) |
| Reads the specified file and returns the contents and length in the variables provided. More...
|
|
int | write (const char *text) |
| Writes the specified text to the file. More...
|
|
int | mkdir (int mode=0777) |
| Creates a directory for the given name. More...
|
|
void | del () |
| Deletes the file.
|
|
|
static const char * | noTerminators [] |
|
Utility wrapper for file objects.
◆ file() [1/3]
xmog::util::file::file |
( |
const char * |
name_ | ) |
|
Create a new file instance representing a file of the given name. The physical file does not need to exist and will not be created by this call.
- Parameters
-
name_ | the name of the file. |
◆ file() [2/3]
xmog::util::file::file |
( |
const std::string & |
name_ | ) |
|
Create a new file instance representing a file of the given name. The physical file does not need to exist and will not be created by this call.
- Parameters
-
name_ | the name of the file. |
◆ file() [3/3]
xmog::util::file::file |
( |
const file & |
parent_, |
|
|
const char *const |
name_ |
|
) |
| |
Create a new file instance based on a file and a name. The physical file does not need to exist and will not be created by this call.
- Parameters
-
parent_ | the file's parent directory. |
name_ | the name of the file in the parent directory. |
◆ list()
size_t xmog::util::file::list |
( |
::std::vector< file > & |
container, |
|
|
const char * |
filter = NULL , |
|
|
file_spec |
fs = fileAndDir , |
|
|
bool |
bRecurse = false , |
|
|
const char * |
terms[] = noTerminators |
|
) |
| const |
Accumulate a list of nested files in accordance with the specified criteria.
- Parameters
-
container | the container into which the nested files are accumulated. |
filter | a simple filename filter that may include one asterisk and multiple questionmarks. An asterisk matches one or more characters, a questionmark matches one character. |
fs | file type filter. By default, we accumulate both files and directories. |
bRecurse | true if we go deep into nested directories. |
◆ mkdir()
int xmog::util::file::mkdir |
( |
int |
mode = 0777 | ) |
|
Creates a directory for the given name.
- Returns
- 0 on success.
◆ operator==()
bool xmog::util::file::operator== |
( |
const std::string & |
name | ) |
const |
|
inline |
Return true if the file names match. The comparison is case sensitive even on case-insensitive platforms.
◆ path()
std::string xmog::util::file::path |
( |
const char * |
filter, |
|
|
file_spec |
fs = onlyFile |
|
) |
| const |
Accumulate a path of nested files in accordance with the specified criteria.
- Parameters
-
filter | a simple filename filter that may include one asterisk and multiple questionmarks. An asterisk matches one or more characters, a questionmark matches one character. |
fs | file type filter. By default, we accumulate only files. |
◆ read()
int xmog::util::file::read |
( |
char ** |
pdata, |
|
|
jint * |
length |
|
) |
| |
Reads the specified file and returns the contents and length in the variables provided.
- Parameters
-
pdata | pointer to variable that will hold read file data on successful return. |
length | pointer to variable that will hold number of read characters on successful return. |
- Returns
- 0 on success.
◆ write()
int xmog::util::file::write |
( |
const char * |
text | ) |
|
Writes the specified text to the file.
- Parameters
-
- Returns
- 0 on success.
The documentation for this class was generated from the following file: