C++ UA Server SDK
1.5.1.326
|
#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 } |
This enum describes the filtering options available to UaDir; e.g. More... | |
enum | SortFlags { NoSort = 0, Name = 1, Time = 2, Size = 4 } |
This enum describes the sort options available to UaDir, e.g. More... | |
Public Member Functions | |
UaDir (const UaUniString &sPath) | |
construction More... | |
~UaDir () | |
destruction | |
UaUniString | getPath () const |
Get the path. More... | |
UaUniString | canonicalPath () const |
Returns the canonical path, i.e. More... | |
UaUniString | filePath (const UaUniString &sFileName) const |
Returns the path name of a file in the directory. More... | |
UaUniStringList | 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. More... | |
bool | cd (const UaUniString &sDirName) |
Changes the UaDir's directory to sDirName. More... | |
bool | copy (const UaUniString &fileName, const UaUniString &newName) |
The copy function copies an existing file to an new file. More... | |
bool | createFile (const UaUniString &sPath, const UaUniString &sFileName) |
Create a new file and opens it for writing. More... | |
bool | isRelativePath (const UaUniString &sPath) const |
Returns true if sPath is relative; returns false if it is absolute. More... | |
bool | link (const UaUniString &fileName, const UaUniString &newName) |
Create a hard link to a new file. More... | |
bool | mkdir (const UaUniString &sDirName) const |
Creates a sub-directory called sDirName See also rmdir. More... | |
bool | mkpath (const UaUniString &sDirName) const |
Creates the directory path sDirName. More... | |
bool | remove (const UaUniString &sFileName) |
Removes the file, sFileName. More... | |
bool | rename (const UaUniString &sOldName, const UaUniString &sNewName) |
Renames a file or directory from sOldName to sNewName, and returns true if successful; otherwise returns false. More... | |
bool | rmdir (const UaUniString &sDirName) const |
Removes the directory specified by dirName. More... | |
bool | rmpath (const UaUniString &sDirPath) const |
Removes the directory path sDirPath. More... | |
bool | exists (const UaUniString &sPath) const |
Checks if the given path still exists or not. More... | |
OpcUa_UInt16 | count (const UaUniString &sPath) const |
Returns the total number of directories and files in the directory. More... | |
Static Public Member Functions | |
static UaUniString | applicationDataPath () |
Get the path to the application folder (username\Application Data). More... | |
static UaUniString | homePath () |
Returns the absolute path of the user's home directory. More... | |
static UaUniString | systemApplicationDataPath () |
Get the path to the application folder (All Users\Application Data). More... | |
static UaUniString | fromNativeSeparators (const UaUniString &sPathName) |
Returns pathName using '/' as file separator. More... | |
static UaUniString | toNativeSeparators (const UaUniString &sPathName) |
Returns pathName with the '/' separators converted to separators that are appropriate for the underlying operating system. More... | |
static UaChar | separator () |
Returns the native directory separator: "/" under Unix (including Mac OS X) and "\\" under Windows. More... | |
The UaDir class provides access to directory structures and their contents. A UaDir is used to manipulate path names, access information regarding paths and files, and manipulate the underlying file system. UA uses "/" as a universal directory separator in the same way that "/" is used as a path separator in URLs. If you always use "/" as a directory separator, UA will translate your paths to conform to the underlying operating system. A UaDir can point to a file using either a relative or an absolute path. Absolute paths begin with the directory separator (optionally preceded by a drive specification under Windows). Relative file names begin with a directory name or a file name and specify a path relative to the current directory. Examples of absolute paths:
On Windows, the second of the examples above will be translated to {C:\My Documents} when used to access files. Examples of relative paths:
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:
Enumerator | |
---|---|
NoSort |
Do not sort. |
Name |
Sort by name. |
Time |
Sort by time (modification time). |
Size |
Sort by file size. |
UaDir::UaDir | ( | const UaUniString & | sPath | ) |
construction
sPath | a path to a file. |
|
static |
Get the path to the application folder (username\Application Data).
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:
bool UaDir::cd | ( | const UaUniString & | sDirName | ) |
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. |
OpcUa_UInt16 UaDir::count | ( | const UaUniString & | sPath | ) | const |
Returns the total number of directories and files in the directory.
sPath | the path to the directory where to count all the files and dirs. |
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. |
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::exists | ( | const UaUniString & | sPath | ) | const |
Checks if the given path still exists or not.
sPath | the path to the file / directory. |
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.
|
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.
|
inline |
Get the path.
|
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:
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::mkdir | ( | const UaUniString & | sDirName | ) | const |
Creates a sub-directory called sDirName See also rmdir.
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::rmdir | ( | const UaUniString & | sDirName | ) | const |
Removes the directory specified by dirName.
See also mkdir().
bool UaDir::rmpath | ( | const UaUniString & | sDirName | ) | 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).
|
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().
|
static |
Get the path to the application folder (All Users\Application Data).
|
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.