Path test1("~/test/$TEST1/.."); // absolute path Path test2("/$HOME/./analyse"); // absolute path Path test3("myFile"); // relative path cout << test1.originalName() << endl; // Test1 is according the POSIX standard if (test1.isStrictlyPosix()){ cout << "test1 is strictly POSIX << endl; } // Test1 is valid if (test1.isValid()){ cout << test1.isValid() << endl; } // if "TEST1=$TEST2 and TEST2=$TEST1"(recursive environment variables) // an exception will be thrown. ~ is replaced by the homedirectory cout << test1.expandedName() << endl; // $HOME is expanded cout << test2.expandedName() << endl; cout << test1.absoluteName() << endl; cout << test2.absoluteName() << endl; cout << test2.baseName() << endl; cout << test1.dirName() << endl; cout << test3.originalName() << endl; // myFile is returned cout << test3.expandedName() << endl; // Nothing is changed cout << test3.absoluteName() << endl; // The current working directory is placed before 'myFile' cout << test3.baseName() << endl; // The current working directory // is returned cout << test3.dirName() << endl; // myFile is returned
Construct a path with the given name. When the name is empty, it is set to . (working directory). It is not checked if the path name is valid. Function isValid() can be used for that purpose.
Copy constructor, copy semantics.
Destructor
Assignment, copy semantics.
Append a string to the path name. When the current path does not end with a / and the string to append does not start with a /, an intermediate / is also added.
Returns the string as given at construction.
Return a string giving the expanded pathname. This means that the environment variables are expanded and the tilde is replaced by the home directory. An expanded name can still be a relative path. An exception is thrown when converting a recursive environment variable results in an endless loop (that is, more than 25 substitutions).
Return the string which giving the absolute pathname. It is generated from the expanded pathname by adding the working directory when needed.
Check if pathname is valid. This function checks for: double slashes, non-printable characters, pathname length and filename lenghts, this function is more OS-specific.
Check if pathname is valid according the POSIX standard. This function checks for double slashes, non-printable characters,pathname length and filename lenghts, all according to the POSIX-standard.
Return length of path name
Return the maximum length a path name can have.
Return the basename of the path; this is only the name of the file. It takes it from the expanded path name.
Return the dirname of the path; this is the directory where the
filename is found. It takes it from the expanded path name.
To get the absolute dirname one could do:
Path tmpPath (myPath.dirName()); String absDir (tmpPath.absoluteName());or
Path tmpPath (myPath.absoluteName()); String absDir (tmpPath.dirName());
Strip otherName from this name. If stripped, the result gets a leading ././ If not stripped, it is tried if name can be stripped from otherName. If stripped, the result gets a trailing /. If still not stripped, it is tried to strip the directory of otherName. If that succeeds, the result gets a leading ./ This is used by RefTable and TableKeyword to ensure that the name of a subtable or referenced table is always relative to the main table.
If the name starts with ././ add otherName to it. If the name ends with /. strip name from otherName and return the remainder. If the name starts with ./ add the directory of otherName to it. It is the opposite of stripDirectory.
Define the maximum number of bytes in a pathname This definition does not use Posix values.
This function is used by expandedName to replace the tilde and to expand the environment variables
This function is used by absoluteName to make a name absolute, this means that the name is described from the root
Remove . and .. from the path name. Also multiple slashes are replaced by a single.
This function is used by expandName and absoluteName. It sets the integer "count" on the next slash or on the end of a string