Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
character(len=*), | intent(in) | :: | cache_key | |||
character(len=*), | intent(in) | :: | module_files(:) | |||
logical, | intent(out) | :: | success |
subroutine store_module_cache(cache_key, module_files, success) character(len=*), intent(in) :: cache_key character(len=*), intent(in) :: module_files(:) logical, intent(out) :: success character(len=:), allocatable :: modules_dir, dest_file, command integer :: i, exitstat ! Get modules cache directory modules_dir = get_cache_subdir('modules') ! Create cache key subdirectory modules_dir = join_path(trim(modules_dir), trim(cache_key)) call ensure_cache_dir(modules_dir, success) if (.not. success) return ! Copy each module file using cross-platform commands success = .true. do i = 1, size(module_files) if (len_trim(module_files(i)) > 0) then dest_file = join_path(trim(modules_dir), trim(extract_filename(module_files(i)))) ! Use cross-platform copy command if (get_os_type() == OS_WINDOWS) then command = 'copy "'//trim(escape_shell_arg(module_files(i)))//'" "'// & trim(escape_shell_arg(dest_file))//'" >nul 2>&1' else command = 'cp "'//trim(escape_shell_arg(module_files(i)))//'" "'// & trim(escape_shell_arg(dest_file))//'" >/dev/null 2>&1' end if call run(command, exitstat=exitstat) if (exitstat /= 0) then success = .false. return end if end if end do end subroutine store_module_cache