FORCES
FORtran lib for Comp. Env. Sys.
|
Path and directory management. More...
Data Types | |
interface | path_join |
Join given path segments with separator if needed. More... | |
Functions/Subroutines | |
subroutine, public | get_cwd (path, status, verbose, raise) |
Get the current working directory. | |
subroutine, public | change_dir (path, status, verbose, raise) |
Change current working directory. | |
subroutine, public | check_path_exists (path, answer, verbose, raise) |
Checks whether a given path exists. | |
subroutine, public | check_path_isfile (path, answer, verbose, raise) |
Checks whether a given path exists and describes a file. | |
subroutine, public | check_path_isdir (path, answer, verbose, raise) |
Checks whether a given path exists and describes a directory. | |
logical function, public | path_exists (path) |
Return .true. if path refers to an existing path. | |
logical function, public | path_isfile (path) |
Return .true. if path is an existing regular file. | |
logical function, public | path_isdir (path) |
Return .true. if path is an existing directory. | |
logical function, public | path_isabs (path) |
Return .true. if path is an absolute pathname. | |
logical function, public | path_isroot (path) |
Return .true. if path is root ('/' or '//' or '///' and so on). | |
subroutine, public | path_splitext (path, root, ext) |
Splitting the path into root and ext. | |
subroutine, public | path_split (path, head, tail) |
Splitting the path into head and tail. | |
subroutine, public | path_parts (path, parts) |
Splitting the path into its components. | |
character(:) function, allocatable, public | path_dirname (path) |
Return the directory name of pathname path. | |
character(:) function, allocatable, public | path_basename (path) |
Return the base name of pathname path. | |
character(:) function, allocatable, public | path_root (path) |
Return the path without its suffix. | |
character(:) function, allocatable, public | path_ext (path) |
Return the file extension of the final path component. | |
character(:) function, allocatable, public | path_stem (path) |
Return the final path component without its suffix. | |
character(:) function, allocatable, public | path_as_posix (path) |
Return the string representation of the path with forward (/) slashes. | |
character(:) function, allocatable, public | path_normpath (path) |
Normalize a pathname by collapsing redundant separators and up-level references. | |
character(:) function, allocatable, public | path_abspath (path) |
Return a normalized absolutized version of the given path. | |
character(:) function, allocatable | path_join_char (p1, p2) |
Join two path segments with separator if needed. | |
character(:) function, allocatable | path_join_char_opt (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15, p16) |
Join given path segments with separator if needed. | |
character(:) function, allocatable | path_join_arr (paths) |
Join given path segments with separator if needed. | |
subroutine | path_msg (msg, path, verbose, raise) |
subroutine | pop (arr) |
character array pop | |
Variables | |
character(len=*), parameter, public | curdir = '.' |
The constant string used by the operating system to refer to the current directory. | |
character(len=*), parameter, public | pardir = '..' |
The constant string used by the operating system to refer to the parent directory. | |
character(len=*), parameter, public | sep = '/' |
The character used by the operating system to separate pathname components. | |
character(len=*), parameter, public | extsep = '.' |
The character which separates the base filename from the extension. | |
character(len=*), parameter, public | linesep = '\n' |
The string used to separate (or, rather, terminate) lines on the current platform. | |
character(len=*), parameter, public | devnull = '/dev/null' |
The file path of the null device. | |
integer(i4), save, public | max_path_comp_len = 256_i4 |
Maximum length of a path component (folder/file names). | |
integer(i4), save, public | max_path_len = 4096_i4 |
Maximum length of a path (16 max. length components). | |
Path and directory management.
Path handling and existence checks for files and directories.
COPYING
and COPYING.LESSER
provided with this software. The complete GNU license text can also be found at http://www.gnu.org/licenses/. subroutine, public mo_os::change_dir | ( | character(*), intent(in) | path, |
integer(i4), intent(out), optional | status, | ||
logical, intent(in), optional | verbose, | ||
logical, intent(in), optional | raise | ||
) |
Change current working directory.
[in] | path | path to change CWD to |
[out] | status | error status (will prevent error raise if present) |
[in] | verbose | Be verbose or not (default: setting of SHOW_MSG/SHOW_ERR) |
[in] | raise | Throw an error if directory can't be opened (default: .true.) |
subroutine, public mo_os::check_path_exists | ( | character(len=*), intent(in) | path, |
logical, intent(out), optional | answer, | ||
logical, intent(in), optional | verbose, | ||
logical, intent(in), optional | raise | ||
) |
Checks whether a given path exists.
[in] | path | given path |
[out] | answer | result |
[in] | verbose | Be verbose or not (default: setting of SHOW_MSG/SHOW_ERR) |
[in] | raise | Throw an error if path does not exist (default: .false.) |
Definition at line 157 of file mo_os.F90.
References path_exists().
subroutine, public mo_os::check_path_isdir | ( | character(len=*), intent(in) | path, |
logical, intent(out), optional | answer, | ||
logical, intent(in), optional | verbose, | ||
logical, intent(in), optional | raise | ||
) |
Checks whether a given path exists and describes a directory.
[in] | path | given path |
[out] | answer | result |
[in] | verbose | Be verbose or not (default: setting of SHOW_MSG/SHOW_ERR) |
[in] | raise | Throw an error if dir does not exist (default: .false.) |
Definition at line 199 of file mo_os.F90.
References path_isdir().
subroutine, public mo_os::check_path_isfile | ( | character(len=*), intent(in) | path, |
logical, intent(out), optional | answer, | ||
logical, intent(in), optional | verbose, | ||
logical, intent(in), optional | raise | ||
) |
Checks whether a given path exists and describes a file.
[in] | path | given path |
[out] | answer | result |
[in] | verbose | Be verbose or not (default: setting of SHOW_MSG/SHOW_ERR) |
[in] | raise | Throw an error if file does not exist (default: .false.) |
Definition at line 178 of file mo_os.F90.
References path_isfile().
subroutine, public mo_os::get_cwd | ( | character(*), intent(out) | path, |
integer(i4), intent(out), optional | status, | ||
logical, intent(in), optional | verbose, | ||
logical, intent(in), optional | raise | ||
) |
Get the current working directory.
[out] | path | the current working directory |
[out] | status | error status (will prevent error raise if present) |
[in] | verbose | Be verbose or not (default: setting of SHOW_MSG/SHOW_ERR) |
[in] | raise | Throw an error if current directory can't be determined (default: .true.) |
Definition at line 81 of file mo_os.F90.
Referenced by path_abspath().
character(:) function, allocatable, public mo_os::path_abspath | ( | character(len=*), intent(in) | path | ) |
Return a normalized absolutized version of the given path.
[in] | path | given path |
Definition at line 590 of file mo_os.F90.
References get_cwd(), path_join_char(), and path_normpath().
character(:) function, allocatable, public mo_os::path_as_posix | ( | character(len=*), intent(in) | path | ) |
character(:) function, allocatable, public mo_os::path_basename | ( | character(len=*), intent(in) | path | ) |
Return the base name of pathname path.
This is the second element of the pair returned by passing path to the subroutine path_split.
[in] | path | given path |
Definition at line 449 of file mo_os.F90.
References path_split().
character(:) function, allocatable, public mo_os::path_dirname | ( | character(len=*), intent(in) | path | ) |
Return the directory name of pathname path.
This is the first element of the pair returned by passing path to the subroutine path_split.
[in] | path | given path |
Definition at line 432 of file mo_os.F90.
References path_split().
logical function, public mo_os::path_exists | ( | character(len=*), intent(in) | path | ) |
Return .true. if path refers to an existing path.
[in] | path | given path |
Definition at line 220 of file mo_os.F90.
References path_exists(), path_isdir(), and path_isfile().
Referenced by check_path_exists(), and path_exists().
character(:) function, allocatable, public mo_os::path_ext | ( | character(len=*), intent(in) | path | ) |
Return the file extension of the final path component.
[in] | path | given path |
Definition at line 481 of file mo_os.F90.
References path_splitext().
logical function, public mo_os::path_isabs | ( | character(len=*), intent(in) | path | ) |
Return .true. if path is an absolute pathname.
[in] | path | given path |
Definition at line 264 of file mo_os.F90.
References path_isabs(), sep, and mo_string_utils::startswith().
Referenced by path_isabs(), and path_join_char().
logical function, public mo_os::path_isdir | ( | character(len=*), intent(in) | path | ) |
Return .true. if path is an existing directory.
[in] | path | given path |
Definition at line 246 of file mo_os.F90.
References path_isdir(), and sep.
Referenced by check_path_isdir(), path_exists(), path_isdir(), and path_isfile().
logical function, public mo_os::path_isfile | ( | character(len=*), intent(in) | path | ) |
Return .true. if path is an existing regular file.
[in] | path | given path |
Definition at line 232 of file mo_os.F90.
References path_isdir(), and path_isfile().
Referenced by check_path_isfile(), path_exists(), and path_isfile().
logical function, public mo_os::path_isroot | ( | character(len=*), intent(in) | path | ) |
Return .true. if path is root ('/' or '//' or '///' and so on).
[in] | path | given path |
Definition at line 278 of file mo_os.F90.
References path_isroot(), sep, and mo_string_utils::startswith().
Referenced by path_isroot(), path_normpath(), and path_parts().
|
private |
Join given path segments with separator if needed.
If a segment is an absolute path, the previous ones will be ignored.
[in] | paths | given paths |
Definition at line 663 of file mo_os.F90.
Referenced by path_normpath().
|
private |
Join two path segments with separator if needed.
If the second segment is an absolute path, the first one will be ignored.
Definition at line 607 of file mo_os.F90.
References mo_string_utils::endswith(), path_isabs(), and sep.
Referenced by path_abspath(), mo_os::path_join::path_join_arr(), and mo_os::path_join::path_join_char_opt().
|
private |
|
private |
character(:) function, allocatable, public mo_os::path_normpath | ( | character(len=*), intent(in) | path | ) |
Normalize a pathname by collapsing redundant separators and up-level references.
Normalize a pathname by collapsing redundant separators and up-level references so that A//B, A/B/, A/./B and A/foo/../B all become A/B. This string manipulation may change the meaning of a path that contains symbolic links.
[in] | path | given path |
Definition at line 531 of file mo_os.F90.
References curdir, pardir, path_isroot(), path_join_arr(), path_parts(), and pop().
Referenced by path_abspath().
subroutine, public mo_os::path_parts | ( | character(len=*), intent(in) | path, |
character(len=len_trim(path)), dimension(:), intent(out), allocatable | parts | ||
) |
Splitting the path into its components.
[in] | path | given path |
[out] | parts | parts of the given path |
Definition at line 394 of file mo_os.F90.
References path_isroot(), path_split(), and sep.
Referenced by path_normpath().
character(:) function, allocatable, public mo_os::path_root | ( | character(len=*), intent(in) | path | ) |
Return the path without its suffix.
[in] | path | given path |
Definition at line 465 of file mo_os.F90.
References path_splitext().
subroutine, public mo_os::path_split | ( | character(len=*), intent(in) | path, |
character(len=*), intent(out), optional | head, | ||
character(len=*), intent(out), optional | tail | ||
) |
Splitting the path into head and tail.
Splitting the path name into a pair head and tail. Here, tail is the last path name component and head is everything leading up to that. If the path ends with an '/' tail is returned empty and if there is no '/' in path head is returned empty. Trailing '/'es are stripped from head unless it is the root.
[in] | path | given path |
[out] | head | everything leading up to the last path component |
[out] | tail | last pathname component |
Definition at line 357 of file mo_os.F90.
References sep.
Referenced by mo_cli::new_cli_parser(), path_basename(), path_dirname(), path_parts(), and path_stem().
subroutine, public mo_os::path_splitext | ( | character(len=*), intent(in) | path, |
character(len=*), intent(out), optional | root, | ||
character(len=*), intent(out), optional | ext | ||
) |
Splitting the path into root and ext.
Splitting the path name into a pair root and ext. Here, ext stands for extension and has the extension string of the specified path while root is everything except this extension.
[in] | path | given path |
[out] | root | root part of path without extension |
[out] | ext | extension of given path (starting with ".") |
Definition at line 305 of file mo_os.F90.
References mo_string_utils::endswith(), extsep, and sep.
Referenced by path_ext(), path_root(), and path_stem().
character(:) function, allocatable, public mo_os::path_stem | ( | character(len=*), intent(in) | path | ) |
Return the final path component without its suffix.
[in] | path | given path |
Definition at line 497 of file mo_os.F90.
References path_split(), and path_splitext().
|
private |
character array pop
Definition at line 699 of file mo_os.F90.
Referenced by path_normpath().
character(len = *), parameter, public mo_os::curdir = '.' |
The constant string used by the operating system to refer to the current directory.
Definition at line 55 of file mo_os.F90.
Referenced by path_normpath().
character(len = *), parameter, public mo_os::devnull = '/dev/null' |
character(len = *), parameter, public mo_os::extsep = '.' |
The character which separates the base filename from the extension.
Definition at line 61 of file mo_os.F90.
Referenced by path_splitext().
character(len = *), parameter, public mo_os::linesep = '\n' |
integer(i4), save, public mo_os::max_path_comp_len = 256_i4 |
integer(i4), save, public mo_os::max_path_len = 4096_i4 |
character(len = *), parameter, public mo_os::pardir = '..' |
The constant string used by the operating system to refer to the parent directory.
Definition at line 57 of file mo_os.F90.
Referenced by path_normpath().
character(len = *), parameter, public mo_os::sep = '/' |
The character used by the operating system to separate pathname components.
Definition at line 59 of file mo_os.F90.
Referenced by path_as_posix(), path_isabs(), path_isdir(), path_isroot(), path_join_char(), path_parts(), path_split(), and path_splitext().