Platform-agnostic system utilities module Provides cross-platform wrappers for common system operations
Check if a file exists (handles both regular files and symlinks)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filepath |
Check if a directory exists
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | dirpath |
Get platform-specific path separator
Count files in a directory
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | directory |
Check if a process exists
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | pid |
Get system temporary directory
Get platform-specific stderr redirection string
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | arg |
Copy a file from source to destination
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | source | |||
character(len=*), | intent(in) | :: | dest | |||
logical, | intent(out) | :: | success | |||
character(len=*), | intent(out), | optional | :: | error_msg |
Copy a directory recursively from source to destination
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | source | |||
character(len=*), | intent(in) | :: | dest | |||
logical, | intent(out) | :: | success | |||
character(len=*), | intent(out), | optional | :: | error_msg |
Remove a file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filepath | |||
logical, | intent(out), | optional | :: | success |
Remove a directory and all its contents
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | dirpath | |||
logical, | intent(out), | optional | :: | success |
Move/rename a file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | source | |||
character(len=*), | intent(in) | :: | dest | |||
logical, | intent(out) | :: | success |
List files in a directory matching a pattern
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | directory | |||
character(len=*), | intent(in) | :: | pattern | |||
character(len=*), | intent(out) | :: | files(:) | |||
integer, | intent(out) | :: | num_files |
Get absolute path of a file
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | filepath | |||
character(len=*), | intent(out) | :: | abs_path | |||
logical, | intent(out), | optional | :: | success |
Get current working directory
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(out) | :: | cwd | |||
logical, | intent(out), | optional | :: | success |
Find files matching a pattern (recursive or non-recursive)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | directory | |||
character(len=*), | intent(in) | :: | pattern | |||
character(len=*), | intent(out) | :: | files(:) | |||
integer, | intent(out) | :: | num_files | |||
logical, | intent(in), | optional | :: | recursive | ||
integer, | intent(in), | optional | :: | max_depth |
Create a directory (with parent directories if needed)
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | dirpath | |||
logical, | intent(out), | optional | :: | success | ||
logical, | intent(in), | optional | :: | create_parents |
Create a symbolic link
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | target | |||
character(len=*), | intent(in) | :: | link_name | |||
logical, | intent(out) | :: | success |
Run a command and capture output
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | command | |||
character(len=*), | intent(out) | :: | output | |||
integer, | intent(out) | :: | exit_code | |||
integer, | intent(in), | optional | :: | timeout |
Sleep for specified seconds
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | seconds |
Kill a process by PID
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
integer, | intent(in) | :: | pid | |||
logical, | intent(out) | :: | success | |||
logical, | intent(in), | optional | :: | force |
Run a command and capture output and exit code to files This is a portable way to replace Unix "command > output 2>&1; echo $? > exit_file"
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | command | |||
character(len=*), | intent(in) | :: | output_file | |||
character(len=*), | intent(in) | :: | exit_file |