#include <cxxtools/file.h>
Public Member Functions | |
| File (const std::string &path) | |
| Constructs a File object from the path path. | |
| File (const FileInfo &fi) | |
| Constructs a File object from a FileInfo object. | |
| File (const File &file) | |
| Copy constructor. | |
| ~File () | |
| Destrctor. | |
| File & | operator= (const File &file) |
| Assignment operator. | |
| const std::string & | path () const |
| Returns the full path of file in the file-system. | |
| std::size_t | size () const |
| Returns the size of the file in bytes. | |
| std::string | dirName () const |
| Returns the parent directory path. | |
| std::string | name () const |
| Returns the file name including an exension. | |
| std::string | baseName () const |
| Returns the file name without the exension. | |
| std::string | extension () const |
| Returns the file name extension or an empty string if not present. | |
| void | resize (std::size_t n) |
| Resizes the file to a new size of n bytes. | |
| void | remove () |
| Removes the file. | |
| void | move (const std::string &to) |
| Moves the file to the location given by to. | |
| void | link (const std::string &newpath) |
| void | symlink (const std::string &newpath) |
Static Public Member Functions | |
| static File | create (const std::string &path) |
| Creates a new file at the path given by path. | |
| static bool | exists (const std::string &path) |
| Returns true if a file exists at path, or false otherwise. | |
Protected Member Functions | |
| File () | |
| Default Constructor. | |
| File | ( | const std::string & | path | ) | [explicit] |
If no file exists at path, an exception of type FileNotFound is thrown.
An exception of type FileNotFound is thrown if the FileInfo does not represent a file.
| const std::string& path | ( | ) | const |
This method may return a relative path, or a fully qualified one depending on how this object was constructed.
| std::string dirName | ( | ) | const |
This method might return an empty string if the node was created without a complete path. If the directory is located in the root directory of a unix file system, a slash ("/") is returned. A returned directory path always ends with a trailing path separator character. (A backslash in Windows and a slash in Unix, for example.)
| void remove | ( | ) |
This object will be invalid after calling this method.
| void move | ( | const std::string & | to | ) |
The File object will stay valid after this method was called and point to the moved file.