#include <uadir.h>
Public Types | |
enum | Filters { NoFilter = 0, Dirs = 1, Files = 2, Drives = 4, NoSymLinks = 8, NoDotAndDotDot = 16, Readable = 32, Writeable = 64, Executable = 128 } |
enum | SortFlags { NoSort = 0, Name = 1, Time = 2, Size = 4 } |
Public Member Functions | |
UaDir (const UaUniString &sPath) | |
~UaDir () | |
UaUniString | getPath () const |
UaUniString | canonicalPath () const |
UaUniString | filePath (const UaUniString &sFileName) const |
UaUniStringList | entryList (const UaUniString &sPath, int filters=UaDir::NoFilter, int sort=UaDir::NoSort) const |
bool | cd (const UaUniString &sDirName) |
bool | copy (const UaUniString &fileName, const UaUniString &newName) |
bool | createFile (const UaUniString &sPath, const UaUniString &sFileName) |
bool | isRelativePath (const UaUniString &sPath) const |
bool | link (const UaUniString &fileName, const UaUniString &newName) |
bool | mkpath (const UaUniString &sDirName) const |
bool | remove (const UaUniString &sFileName) |
bool | rename (const UaUniString &sOldName, const UaUniString &sNewName) |
bool | rmpath (const UaUniString &sDirPath) const |
bool | exists (const UaUniString &sPath) const |
OpcUa_UInt16 | count (const UaUniString &sPath) const |
Static Public Member Functions | |
static UaUniString | applicationDataPath () |
static UaUniString | homePath () |
static UaUniString | systemApplicationDataPath () |
static UaUniString | fromNativeSeparators (const UaUniString &sPathName) |
static UaUniString | toNativeSeparators (const UaUniString &sPathName) |
static UaChar | separator () |
{C:\My Documents} when used to access files. Examples of relative paths: UaDir("images/landscape.png")
enum UaDir::Filters |
This enum describes the filtering options available to UaDir; e.g. for entryList(). The filter value is specified by combining values from the following list using the bitwise OR operator:
enum UaDir::SortFlags |
This enum describes the sort options available to UaDir, e.g. for entryList(). The sort value is specified by OR-ing together values from the following list:
UaDir::UaDir | ( | const UaUniString & | sPath | ) |
construction
sPath | a path to a file. |
UaDir::~UaDir | ( | ) |
destruction
UaUniString UaDir::getPath | ( | ) | const [inline] |
Get the path.
UaUniString UaDir::canonicalPath | ( | ) | const |
Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements. On systems that do not have symbolic links this function will always return the same string that absolutePath() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns an empty string. Example:
UaUniString bin = "/local/bin"; // where /local/bin is a symlink to /usr/bin UaDir binDir(bin); UaUniString canonicalBin = binDir.canonicalPath(); // canonicalBin now equals "/usr/bin" UaUniString ls = "/local/bin/ls"; // where ls is the executable "ls" UaDir lsDir(ls); UaUniString canonicalLs = lsDir.canonicalPath(); // canonicalLS now equals "/usr/bin/ls".
UaUniString UaDir::filePath | ( | const UaUniString & | sFileName | ) | const |
Returns the path name of a file in the directory. Does not check if the file actually exists in the directory. If the UaDir is relative the returned path name will also be relative. Redundant multiple separators or "." and ".." directories in fileName are not removed.
UaUniStringList UaDir::entryList | ( | const UaUniString & | sPath, | |
int | filters = UaDir::NoFilter , |
|||
int | sort = UaDir::NoSort | |||
) | const |
Returns a list of the names of all the files and directories in the directory, ordered according to the name and attribute filters. The attribute filter and sorting specifications can be overridden using the filters and sort arguments.
bool UaDir::cd | ( | const UaUniString & | sDirName | ) |
Changes the UaDir's directory to sDirName. Returns true if the new directory exists and is readable; otherwise returns false. Note that the logical cd() operation is not performed if the new directory does not exist.
bool UaDir::copy | ( | const UaUniString & | fileName, | |
const UaUniString & | newName | |||
) |
The copy function copies an existing file to an new file.
fileName | the original file name to copy. | |
newName | the new name of the copied file. |
bool UaDir::createFile | ( | const UaUniString & | sPath, | |
const UaUniString & | sFileName | |||
) |
Create a new file and opens it for writing.
sPath | path to the new file. | |
sFileName | the name of the new file. |
bool UaDir::isRelativePath | ( | const UaUniString & | sPath | ) | const |
Returns true if sPath is relative; returns false if it is absolute. (Under Unix a path is relative if it does not start with a "/").
bool UaDir::link | ( | const UaUniString & | fileName, | |
const UaUniString & | newName | |||
) |
Create a hard link to a new file. Establishes a hard link between an existing file and a new file.
fileName | path to the file to link with. | |
newName | the new name of the linked file. |
bool UaDir::mkpath | ( | const UaUniString & | sDirName | ) | const |
Creates the directory path sDirName. The function will create all parent directories necessary to create the directory.
bool UaDir::remove | ( | const UaUniString & | sFileName | ) |
Removes the file, sFileName.
bool UaDir::rename | ( | const UaUniString & | sOldName, | |
const UaUniString & | sNewName | |||
) |
Renames a file or directory from sOldName to sNewName, and returns true if successful; otherwise returns false. On most file systems, rename() fails only if sOldName does not exist, if sNewName and sOldName are not on the same partition or if a file with the new name already exists. However, there are also other reasons why rename() can fail. For example, on at least one file system rename() fails if sNewName points to an open file.
bool UaDir::rmpath | ( | const UaUniString & | sDirPath | ) | const |
Removes the directory path sDirPath. The function will remove all parent directories in sDirPath, provided that they are empty. This is the opposite of mkpath(sDirName).
bool UaDir::exists | ( | const UaUniString & | sPath | ) | const |
Checks if the given path still exists or not.
sPath | the path to the file / directory. |
OpcUa_UInt16 UaDir::count | ( | const UaUniString & | sPath | ) | const |
Returns the total number of directories and files in the directory (including "." and "..")
sPath | the path to the directory where to count all the files and dirs. |
UaUniString UaDir::applicationDataPath | ( | ) | [static] |
Get the path to the application folder (<username> Data).
UaUniString UaDir::homePath | ( | ) | [static] |
Returns the absolute path of the user's home directory. Under Windows this function will return the directory of the current user's profile. Typically, this is:
C:/Documents and Settings/Username
UaUniString UaDir::systemApplicationDataPath | ( | ) | [static] |
Get the path to the application folder (All Users Data).
UaUniString UaDir::fromNativeSeparators | ( | const UaUniString & | sPathName | ) | [static] |
Returns pathName using '/' as file separator. On Windows, for instance, fromNativeSeparators("c:\\winnt\\system32") returns "c:/winnt/system32". The returned string may be the same as the argument on some operating systems, for example on Unix.
UaUniString UaDir::toNativeSeparators | ( | const UaUniString & | sPathName | ) | [static] |
Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system. On Windows, toNativeSeparators("c:/winnt/system32") returns "c:\\winnt\\system32". The returned string may be the same as the argument on some operating systems, for example on Unix.
UaChar UaDir::separator | ( | ) | [static] |
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows. You do not need to use this function to build file paths. If you always use "/", Ua will translate your paths to conform to the underlying operating system. If you want to display paths to the user using their operating system's separator use toNativeSeparators().