Skip to content

figure_files ​

figure_files, files and folders: make, remove, time, test, the same on every platform.

Standard Fortran opens, reads and writes files, and inquire tests a file, but it has no way to make a folder, remove one, or set a file's time; execute_command_line with mkdir -p or touch works where a POSIX shell runs it, not on Windows, where it runs cmd.exe. These procedures do it in the native layer (C++'s std::filesystem, the system's file times), the same on Linux, macOS and Windows. Paths are UTF-8, with / separators (also \ on Windows); a relative path is taken from the working folder. Any thread, any time (no init* needed).

Source: src/lib/figure_files.F90

Dependencies

Contents ​

Subroutines ​

figure_make_folder ​

Make the folder path, and its missing parents unless parents=.false.; a folder already there is no error, a file there is (FIG_ERR_FAILED).

Attributes: recursive

fortran
subroutine figure_make_folder(path, parents, stat)

Arguments

NameTypeIntentAttributesDescription
pathcharacter(len=*)inFolder.
parentslogicalinoptionalMake the missing parents (default .true., as mkdir -p).
statinteger(kind=int32)outoptionalFIG_ERR_ARGUMENT for an empty path.

Call graph

figure_remove ​

Remove the file or empty folder path, or with recursive=.true. a folder and everything in it; a path that does not exist is no error (as rm -f), so a program clears without testing first.

Attributes: recursive

fortran
subroutine figure_remove(path, recursive, stat)

Arguments

NameTypeIntentAttributesDescription
pathcharacter(len=*)inFile or folder.
recursivelogicalinoptionalRemove a folder's content too (default .false.).
statinteger(kind=int32)outoptionalfolder not empty), FIG_ERR_ARGUMENT for an empty path.

Call graph

figure_set_file_time ​

Set the modification time of the file or folder path to time, a local time 'YYYY-MM-DD hh:mm' or 'YYYY-MM-DD hh:mm:ss' (as touch -t): a listing shows the same time on every machine set to that time zone.

Attributes: recursive

fortran
subroutine figure_set_file_time(path, time, stat)

Arguments

NameTypeIntentAttributesDescription
pathcharacter(len=*)inFile or folder.
timecharacter(len=*)inLocal time, 'YYYY-MM-DD hh:mm[:ss]'.
statinteger(kind=int32)outoptionala date, FIG_ERR_FAILED for a path that cannot be set.

Call graph

Functions ​

figure_file_time ​

The modification time of the file or folder path, local, 'YYYY-MM-DD hh:mm:ss'; blank on a failure.

Attributes: recursive

Returns: character(len=19)

fortran
function figure_file_time(path, stat) result(time)

Arguments

NameTypeIntentAttributesDescription
pathcharacter(len=*)inFile or folder.
statinteger(kind=int32)outoptionalStatus: FIG_ERR_FAILED for a path that does not exist.

Call graph

figure_file_exists ​

Whether path exists, a file or a folder (what inquire(file=) says of a folder is the compiler's choice).

Attributes: recursive

Returns: logical

fortran
function figure_file_exists(path) result(exists)

Arguments

NameTypeIntentAttributesDescription
pathcharacter(len=*)inFile or folder.

Call graph

Released under the MIT licence.