#include <stfile.h>
Public Member Functions | |
StFile () | |
StFile (const StString &path, bool followSymLinks=false) | |
StFile (const char *path, bool followSymLinks=false) | |
StFile (const StFile ©) | |
~StFile () | |
void | setPath (const StString &path, bool followSymLinks=false) |
StString | getPath () const |
StString | getBaseName () |
bool | exists () const |
void | readStat (bool followSymLinks=true) |
bool | isDirectory () const |
bool | isSymLink () const |
bool | isRegular () const |
bool | isCharacterDevice () const |
bool | isBlockDevice () const |
bool | isFifo () const |
bool | isSocket () const |
long | size () const |
bool | remove () |
bool | move (StString dest, bool overwrite=false) |
bool | copy (StString dest, bool overwrite=false) |
StPermission | getPermissions () const |
bool | changePermissions (const StPermission &perm) |
bool | changeOwner (const StPermission &perm) |
bool | open (SmartTools::OpenFileMode mode) |
bool | open (const StString &mode) |
void | close () |
unsigned | read (void *buffer, unsigned size, unsigned count=1) |
unsigned | write (const void *buffer, unsigned size, unsigned count=1) |
StString | getLine () |
bool | isEndOfFile () |
void | operator= (const StString &path) |
operator StString () const | |
StFile & | operator<< (const StString &string) |
void | clear () |
Private Member Functions | |
void | init () |
Private Attributes | |
StString | path |
bool | _exists |
stat | st |
FILE * | fPointer |
With StFile you can open, close, read, write, move, copy, and remove a file. It also allows operation on a file's permissions.
StFile::StFile | ( | ) | [inline] |
StFile::StFile | ( | const StString & | path, | |
bool | followSymLinks = false | |||
) |
StFile::StFile | ( | const char * | path, | |
bool | followSymLinks = false | |||
) | [inline] |
StFile::StFile | ( | const StFile & | copy | ) | [inline] |
StFile::~StFile | ( | ) | [inline] |
bool StFile::changeOwner | ( | const StPermission & | perm | ) |
Change owner and/or group if given.
bool StFile::changePermissions | ( | const StPermission & | perm | ) |
Change file's permissions
void StFile::clear | ( | ) |
Clear path and file's pointer.
void StFile::close | ( | ) | [inline] |
Close file.
bool StFile::copy | ( | StString | dest, | |
bool | overwrite = false | |||
) |
Copy file to the dest.
bool StFile::exists | ( | ) | const [inline] |
StString StFile::getBaseName | ( | ) |
StString StFile::getPath | ( | ) | const [inline] |
StPermission StFile::getPermissions | ( | ) | const |
void StFile::init | ( | ) | [private] |
bool StFile::isBlockDevice | ( | ) | const [inline] |
bool StFile::isCharacterDevice | ( | ) | const [inline] |
bool StFile::isDirectory | ( | ) | const [inline] |
bool StFile::isEndOfFile | ( | ) | [inline] |
bool StFile::isFifo | ( | ) | const [inline] |
bool StFile::isRegular | ( | ) | const [inline] |
bool StFile::isSocket | ( | ) | const [inline] |
bool StFile::isSymLink | ( | ) | const [inline] |
bool StFile::move | ( | StString | dest, | |
bool | overwrite = false | |||
) |
Move file to the dest and change current path if succeed.
bool StFile::open | ( | const StString & | mode | ) |
Open file.
bool StFile::open | ( | SmartTools::OpenFileMode | mode | ) |
Open file.
StFile::operator StString | ( | ) | const [inline] |
Return path of file.
Write string to file.
void StFile::operator= | ( | const StString & | path | ) | [inline] |
Set the path to the file.
unsigned StFile::read | ( | void * | buffer, | |
unsigned | size, | |||
unsigned | count = 1 | |||
) | [inline] |
Read from file to the buffer.
*buffer | Pointer to the destination structure with a minimum size of (size*count) bytes. | |
size | Size in bytes for each item to be read. | |
count | Number of items, each one with a size in bytes. |
void StFile::readStat | ( | bool | followSymLinks = true |
) |
Read current file state
bool StFile::remove | ( | ) |
Remove a file.
void StFile::setPath | ( | const StString & | path, | |
bool | followSymLinks = false | |||
) | [inline] |
Set path to the file. It can follow symlinks.
long StFile::size | ( | ) | const [inline] |
unsigned StFile::write | ( | const void * | buffer, | |
unsigned | size, | |||
unsigned | count = 1 | |||
) | [inline] |
Write from buffer to the file.
*buffer | Pointer to data to be written. | |
size | Size in bytes of each item that has to be written. | |
count | Number of items, each one with a size in bytes. |
bool StFile::_exists [private] |
FILE* StFile::fPointer [private] |
StString StFile::path [private] |
struct stat StFile::st [private] |