Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | cache_key | |||
character(len=*), | intent(in) | :: | executable_path | |||
logical, | intent(out) | :: | success |
subroutine store_executable_cache(cache_key, executable_path, success) character(len=*), intent(in) :: cache_key, executable_path logical, intent(out) :: success character(len=:), allocatable :: executables_dir, dest_file, command integer :: exitstat ! Get executables cache directory executables_dir = get_cache_subdir('executables') ! Create cache key subdirectory executables_dir = join_path(trim(executables_dir), trim(cache_key)) call ensure_cache_dir(executables_dir, success) if (.not. success) return ! Copy executable using cross-platform commands dest_file = join_path(trim(executables_dir), trim(extract_filename(executable_path))) if (get_os_type() == OS_WINDOWS) then command = 'copy "'//trim(escape_shell_arg(executable_path))//'" "'// & trim(escape_shell_arg(dest_file))//'" >nul 2>&1' else command = 'cp "'//trim(escape_shell_arg(executable_path))//'" "'// & trim(escape_shell_arg(dest_file))//'" >/dev/null 2>&1' end if call run(command, exitstat=exitstat) success = (exitstat == 0) if (success .and. get_os_type() /= OS_WINDOWS) then ! Make executable (not needed on Windows) command = 'chmod +x "'//trim(escape_shell_arg(dest_file))//'"' call run(command, exitstat=exitstat) success = (exitstat == 0) end if end subroutine store_executable_cache