From dd6ac6fc0fedd377bb95f92616aec29a01f0dcbf Mon Sep 17 00:00:00 2001 From: LKedward Date: Mon, 7 Sep 2020 10:10:02 +0100 Subject: Fix: for windows paths Adds windows_path filesystem function to convert to windows compatible paths --- fpm/src/fpm_filesystem.f90 | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/fpm/src/fpm_filesystem.f90 b/fpm/src/fpm_filesystem.f90 index 59be19a..8d92ced 100644 --- a/fpm/src/fpm_filesystem.f90 +++ b/fpm/src/fpm_filesystem.f90 @@ -5,7 +5,7 @@ implicit none private public :: basename, join_path, number_of_rows, read_lines, list_files,& - mkdir, exists, get_temp_filename + mkdir, exists, get_temp_filename, windows_path integer, parameter :: LINE_BUFFER_LEN = 1000 @@ -119,8 +119,8 @@ subroutine mkdir(dir) call execute_command_line("mkdir -p " // dir , exitstat=stat) write(*,*) "mkdir -p " // dir case (OS_WINDOWS) - call execute_command_line("mkdir " // dir, exitstat=stat) - write(*,*) "mkdir " // dir + call execute_command_line("mkdir " // windows_path(dir), exitstat=stat) + write(*,*) "mkdir " // windows_path(dir) end select if (stat /= 0) then print *, "execute_command_line() failed" @@ -153,7 +153,7 @@ subroutine list_files(dir, files) call execute_command_line("ls " // dir // " > "//temp_file, & exitstat=stat) case (OS_WINDOWS) - call execute_command_line("dir /b " // dir // " > "//temp_file, & + call execute_command_line("dir /b " // windows_path(dir) // " > "//temp_file, & exitstat=stat) end select if (stat /= 0) then @@ -213,4 +213,18 @@ function get_temp_filename() result(tempfile) end function get_temp_filename +function windows_path(path) result(winpath) + ! Replace file system separators for windows + ! + character(*), intent(in) :: path + character(:), allocatable :: winpath + + winpath = path + + do while(index(winpath,'/') > 0) + winpath(index(winpath,'/'):index(winpath,'/')) = '\' + end do + +end function windows_path + end module fpm_filesystem -- cgit v1.2.3