limal::path Namespace Reference
The LiMaL path utility namespace.
More...
Classes |
class | PathInfo |
| Wrapper class for stat/lstat and other file/directory related operations. More...
|
class | PathName |
| PathName manipulation class. More...
|
Functions |
bool | operator== (const PathName &lname, const PathName &rname) |
bool | operator!= (const PathName &lname, const PathName &rname) |
PathName | operator+ (const PathName &lname, const PathName &rname) |
std::ostream & | operator<< (std::ostream &ostr, const PathName &path) |
int | createDir (const PathName &path, mode_t mode=0755) |
| Create a directory.
|
int | createDirRecursive (const PathName &path, mode_t mode=0755) |
int | removeDir (const PathName &path) |
| Remove a directory.
|
int | removeDirRecursive (const PathName &path) |
| Remove a directory recursively.
|
int | copyDir (const PathName &srcPath, const PathName &destPath) |
int | readDir (BLOCXX_NAMESPACE::List< BLOCXX_NAMESPACE::String > &retlist, const PathName &path, bool dots) |
int | removeFile (const PathName &path) |
int | moveFile (const PathName &oldPath, const PathName &newPath) |
int | copyFile (const PathName &file, const PathName &dest) |
int | symLink (const PathName &oldPath, const PathName &newPath) |
int | changeMode (const PathName &path, mode_t mode) |
Detailed Description
The LiMaL path utility namespace.
Function Documentation
int limal::path::changeMode |
( |
const PathName & |
path, |
|
|
mode_t |
mode | |
|
) |
| | |
Like 'chmod'. The mode of the file given by path is changed.
- Returns:
- 0 on success, errno on failure
int limal::path::copyDir |
( |
const PathName & |
srcPath, |
|
|
const PathName & |
destPath | |
|
) |
| | |
Like 'cp -a srcPath destPath'. Copy directory tree. srcpath/destpath must be directories. 'basename srcpath' must not exist in destpath.
- Returns:
- 0 on success, ENOTDIR if srcpath/destpath is not a directory, EEXIST if 'basename srcpath' exists in destpath, otherwise the commands return value.
- Todo:
- Rewrite not to execute shell command 'cp -a <srcPath> <destPath>'
int limal::path::copyFile |
( |
const PathName & |
file, |
|
|
const PathName & |
dest | |
|
) |
| | |
Like 'cp file dest'. Copy file to destination file.
- Returns:
- 0 on success, EINVAL if file is not a file, EISDIR if destiantion is a directory, otherwise the commands return value.
int limal::path::createDir |
( |
const PathName & |
path, |
|
|
mode_t |
mode = 0755 | |
|
) |
| | |
Create a directory.
Like 'mkdir'. Attempt to create a new directory with name 'path'. The parameter 'mode' specifies the permissions bits to use. It is modified by the process's umask in the usual way.
The directory's user ID is set to the process' effective user ID, the group ID to the effective group ID of the process or inherited from the parent directory if the set group ID bit is set or if specified by mount options.
- Parameters:
-
| path | The path name of the new directory. |
| mode | The permissions bits of the new directory. |
- Returns:
- 0 on success, errno value on failure
int limal::path::createDirRecursive |
( |
const PathName & |
path, |
|
|
mode_t |
mode = 0755 | |
|
) |
| | |
Create a directory with parent directories as needed.
Like 'mkdir -p'. Attempt to create a new directory with name 'path' and all parent directories as needed. The parameter 'mode' specifies the permissions bits to use. It is modified by the process's umask in the usual way. No error is reported if the directory already exists.
- Parameters:
-
| path | The path name of the new directory. |
| mode | The permissions bits of the new directory. |
- Returns:
- 0 on success, errno value on failure
int limal::path::moveFile |
( |
const PathName & |
oldPath, |
|
|
const PathName & |
newPath | |
|
) |
| | |
Like 'rename'. Renames a file, moving it between directories if required.
- Returns:
- 0 on success, errno on failure
bool limal::path::operator!= |
( |
const PathName & |
lname, |
|
|
const PathName & |
rname | |
|
) |
| | [inline] |
PathName limal::path::operator+ |
( |
const PathName & |
lname, |
|
|
const PathName & |
rname | |
|
) |
| | [inline] |
std::ostream& limal::path::operator<< |
( |
std::ostream & |
ostr, |
|
|
const PathName & |
path | |
|
) |
| | |
bool limal::path::operator== |
( |
const PathName & |
lname, |
|
|
const PathName & |
rname | |
|
) |
| | [inline] |
int limal::path::readDir |
( |
BLOCXX_NAMESPACE::List< BLOCXX_NAMESPACE::String > & |
retlist, |
|
|
const PathName & |
path, |
|
|
bool |
dots | |
|
) |
| | |
Return content of directory via retlist. If dots is false entries starting with '.' are not reported. "." and ".." are never reported.
- Returns:
- 0 on success, errno on failure.
int limal::path::removeDir |
( |
const PathName & |
path |
) |
|
Remove a directory.
Like 'rmdir'. Delete a directory, which must be empty.
- Parameters:
-
| path | The path to the directory. |
- Returns:
- 0 on success, errno value on failure
int limal::path::removeDirRecursive |
( |
const PathName & |
path |
) |
|
Remove a directory recursively.
Like 'rm -r path'. Delete a directory, recursively removing its contents.
- Parameters:
-
| path | The path to the directory. |
- Returns:
- 0 on success, ENOTDIR if the specified path is not a directory, otherwise the commands return value.
- Todo:
- Rewrite not to execute shell command 'rm -rf --preserve-root -- <path>'.
int limal::path::removeFile |
( |
const PathName & |
path |
) |
|
Like 'unlink'. Delete a file (symbolic link, socket, fifo or device).
- Returns:
- 0 on success, errno on failure
int limal::path::symLink |
( |
const PathName & |
oldPath, |
|
|
const PathName & |
newPath | |
|
) |
| | |
Like 'symlink'. Creates a symbolic link named newpath which contains the string oldpath. If newpath exists it will not be overwritten.
- Returns:
- 0 on success, errno on failure.