C++ Based OPC UA Client/Server SDK  1.5.5.355
UaDir Class Reference

UaDir. More...

#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...
 

Detailed Description

UaDir.

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:

UaDir("/home/user/Documents")
UaDir("C:/Documents and Settings")

On Windows, the second of the examples above will be translated to {C:\My Documents} when used to access files. Examples of relative paths:

UaDir("images/landscape.png")

Member Enumeration Documentation

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:

Enumerator
NoFilter 

no filter

Dirs 

List directories that match the filters.

Files 

List files only.

Drives 

List disk drives (ignored under Unix).

NoSymLinks 

Do not list symbolic links (ignored by operating systems that don't support symbolic links).

NoDotAndDotDot 

Do not list the special entries "." and "..".

Readable 

List files for which the application has read access. The Readable value needs to be combined with Dirs or Files.

Writeable 

List files for which the application has write access. The Writable value needs to be combined with Dirs or Files.

Executable 

List files for which the application has execute access. The Executable value needs to be combined with Dirs or Files.

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.

Constructor & Destructor Documentation

UaDir::UaDir ( const UaUniString sPath)

construction

Parameters
sPatha path to a file.

Member Function Documentation

UaUniString UaDir::applicationDataPath ( )
static

Get the path to the application folder (username\Application Data).

Returns
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:

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".
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.

Parameters
fileNamethe original file name to copy.
newNamethe new name of the copied file.
Returns
true if successful false if not.
OpcUa_UInt16 UaDir::count ( const UaUniString sPath) const

Returns the total number of directories and files in the directory.

Parameters
sPaththe path to the directory where to count all the files and dirs.
Returns
the total number of directories and files.
bool UaDir::createFile ( const UaUniString sPath,
const UaUniString sFileName 
)

Create a new file and opens it for writing.

Parameters
sPathpath to the new file.
sFileNamethe name of the new file.
Returns
true if successful false if not.
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.

Returns
an empty list if the directory is unreadable, does not exist, or if nothing matches the specification.
bool UaDir::exists ( const UaUniString sPath) const

Checks if the given path still exists or not.

Parameters
sPaththe path to the file / directory.
Returns
true if the path exists, false if not.
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.

See also
canonicalPath()
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.

See also
toNativeSeparators()
UaUniString UaDir::getPath ( ) const
inline

Get the path.

Returns
the path.
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
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.

Parameters
fileNamepath to the file to link with.
newNamethe new name of the linked file.
Returns
true if successfull false if not.
bool UaDir::mkdir ( const UaUniString sDirName) const

Creates a sub-directory called sDirName See also rmdir.

Returns
true if successful false if not.
bool UaDir::mkpath ( const UaUniString sDirName) const

Creates the directory path sDirName.

The function will create all parent directories necessary to create the directory.

Returns
true if successful; otherwise returns false.
See also
rmpath()
bool UaDir::remove ( const UaUniString sFileName)

Removes the file, sFileName.

Returns
true if the file is removed successfully; otherwise returns false.
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().

Returns
true if successful false if not.
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).

Returns
true if successful; otherwise returns false.
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().

UaUniString UaDir::systemApplicationDataPath ( )
static

Get the path to the application folder (All Users\Application Data).

Returns
the path to the application folder (All Users\Application Data).
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.


The documentation for this class was generated from the following files: