temp_utils Module


Uses


Derived Types

type, public ::  temp_dir_manager

Components

Type Visibility Attributes Name Initial
character(len=:), public, allocatable :: path
logical, public :: cleanup_on_destroy = .true.

Finalizations Procedures

final :: temp_dir_destroy

Type-Bound Procedures

procedure, public :: create => temp_dir_create
procedure, public :: get_path => temp_dir_get_path
procedure, public :: get_file_path => temp_dir_get_file_path
procedure, public :: cleanup => temp_dir_cleanup

Functions

public function create_temp_dir(prefix) result(temp_dir)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: prefix

Return Value character(len=:), allocatable

public function create_temp_file(prefix, extension) result(temp_file)

Create a unique temporary file path without creating a directory

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: prefix
character(len=*), intent(in), optional :: extension

Return Value character(len=:), allocatable

public function get_temp_file_path(temp_dir, filename) result(file_path)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: temp_dir
character(len=*), intent(in) :: filename

Return Value character(len=:), allocatable

public function get_system_temp_dir() result(temp_dir)

Arguments

None

Return Value character(len=:), allocatable

public function get_current_directory() result(cwd)

Arguments

None

Return Value character(len=:), allocatable

public function get_project_root() result(root_dir)

Arguments

None

Return Value character(len=:), allocatable

public function path_join(path1, path2) result(joined_path)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: path1
character(len=*), intent(in) :: path2

Return Value character(len=:), allocatable

public function create_test_cache_dir(test_name) result(cache_dir)

Create a unique test cache directory to avoid race conditions in parallel tests

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: test_name

Return Value character(len=:), allocatable

public function fortran_with_isolated_cache(test_name) result(command_prefix)

Create a command that runs fortrun with isolated cache

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: test_name

Return Value character(len=:), allocatable

public function fortran_with_cache_dir(cache_dir) result(command_prefix)

Create a command that runs fortrun with specified cache directory

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: cache_dir

Return Value character(len=:), allocatable


Subroutines

public subroutine cleanup_temp_dir(temp_dir)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: temp_dir

public subroutine mkdir(dir_path)

Safe mkdir that creates parent directories and doesn't terminate on failure (unlike FPM's mkdir)

Arguments

Type IntentOptional Attributes Name
character(len=*), intent(in) :: dir_path