#include <rtfile.h>
Public Methods | |
| File () | |
| Creates an invalid file descriptor. | |
| File (const String &name) | |
| Creates a file descriptor for the given file name. More... | |
| File (const File &) | |
| Creates a file descriptor by copying over the given one. | |
| File (const File &parent, const String &child) | |
| Creates a file descriptor for the given file name. More... | |
| File & | operator= (const File &) |
| Copies all data over from the given file descriptor. | |
| ~File () | |
| String | getName () const |
| Returns the absolute file name, using the system's path separator, of this file. | |
| String | getFileName () const |
| Returns the file name, relative to the folder in which it is contained. More... | |
| String | getLocalName (const File &relFile=(*currentFolder)) const |
| Returns a local file name, using the system's path separator, of this file. More... | |
| String | getParent () const |
| Returns the absolute file name, using the system's path separator, of this file's parent folder. | |
| File | getParentFile () const |
| Returns a file descriptor for this file's parent folder. More... | |
| bool | isFolder () const |
Returns true if this file descriptor denotes a folder. | |
| bool | isFile () const |
Returns true if this file descriptor denotes a normal file (and not a folder). | |
| bool | exists () |
Returns true if this file exists. | |
| bool | canWrite () |
Returns true if the application can write to the file denoted by this file descriptor. | |
| bool | canRead () |
Returns true if the application can read from the file denoted by this file descriptor. | |
| int | getSize () |
| Returns the file's size, or -1 if it does not exist. | |
| Time | getLastModified () |
| Returns the file's last modification date, or the epoch if it doesn't exist. | |
| InputStream * | openRead (bool textMode) |
| Opens this file for reading, if it exists. More... | |
| OutputStream * | openWrite () |
| Opens this file for overwriting, if it exists and can be written to. | |
| OutputStream * | openAppend () |
| Opens this file for appending, if it exists and can be written to. | |
| Array< File > | list () |
| Lists all files and folders contained in this folder. More... | |
| Array< File > | list (const IFilenameFilter *) |
| Lists all files and folders contained in this folder which match the given filename filter. More... | |
Static Public Methods | |
| void | setCurrentFolder (const File &newFolder) |
| Sets the "current folder" to the given new folder. More... | |
| const String | getCurrentFolder () |
| Returns the "current folder". More... | |
| const File | getExecutableFile () |
| Returns the executable program's file name (if available). More... | |
| const File | getHomeFolder () |
| Returns a file descriptor for the current user's home folder. More... | |
| const File | getSettingsFolder () |
| Returns a file descriptor for the current user's LRT settings folder. More... | |
| bool | createFolder (const File &folder) |
| Creates the folder as given by its file descriptor. More... | |
| void | initialize (const String &executableFileName) |
Initializes the File class. More... | |
| void | finalize () |
Finalizes the File class. More... | |
| bool | isAbsolute (const String &fname) |
| Checks if the given file name is absolute. | |
Static Public Attributes | |
| const char | separatorChar = '\\' |
The character used to separate path components in Files. More... | |
| const String | separator = "\\" |
The character used to separate path components in Files. More... | |
| const bool | caseSensitive = false |
| Are file names case sensitive? | |
Friends | |
| class | File::FileAttributes |
It provides methods to query file attributes, open files, and list folders.
When using libRT to open files, you should specify their names separated with forward slashes '/'. The File class will automatically convert them to the system dependent file name separator. Also, when constructing a File which denotes a folder, you must append a slash to its name.
Examples:
"c:/Programs" means the file called "Programs" in folder "c:".
"/usr/bin/" means the folder "bin" in folder "usr", specified as an absolute path.
"test/test.txt" means the file "test.txt" in the subfolder "test" of the current folder (see getCurrentFolder() for this).
"../xyz.txt" means the file "xyz.txt", one folder up from the current folder.
|
|
Creates a file descriptor for the given file name. If the given name is not absolute, it is resolved against the current folder. |
|
||||||||||||
|
Creates a file descriptor for the given file name. If the name is not absolute, it is resolved against the given parent file descriptor.
|
|
|
Creates the folder as given by its file descriptor. If the given file descriptor is a file, its parent is created instead.
|
|
|
Finalizes the
As this method is automatically called by |
|
|
Returns the "current folder". All relative paths are resolved to this folder. |
|
|
Returns the executable program's file name (if available).
Note that the |
|
|
Returns the file name, relative to the folder in which it is contained. (This is the local file name without any folders prefixed.) |
|
|
Returns a file descriptor for the current user's home folder. Under Unix systems, this is the contents of the $HOME environment variable, under Windows, the "My Documents" folder is returned. |
|
|
Returns a local file name, using the system's path separator, of this file.
|
|
|
Returns a file descriptor for this file's parent folder. If this file descriptor already denotes a root folder, it is returned unchanged. |
|
|
Returns a file descriptor for the current user's LRT settings folder. This folder may be used to store application preferences and settings files. Under Unix, this is the $HOME/.lrt/ folder, on Windows it is either the "Application Data" folder (W2K etc.) or the program's folder. Note that you may have to create the settings folder first using createFolder(). |
|
|
Initializes the
You should never call this method from applications. |
|
|
Lists all files and folders contained in this folder which match the given filename filter.
|
|
|
Lists all files and folders contained in this folder.
If this file descriptor does not denote a folder, the contents of its parent folder are returned instead. If this file doesn't exist, a zero-length array is returned. |
|
|
Opens this file for reading, if it exists.
You should always call
|
|
|
Sets the "current folder" to the given new folder.
The current folder is the one, to which all relative paths are resolved. |
|
|
The character used to separate path components in Represented as a String for your convenience. |
|
|
The character used to separate path components in
For example, it is ' |