diff options
author | Milan Curcic <caomaco@gmail.com> | 2020-10-26 17:25:47 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-26 17:25:47 -0400 |
commit | e92d9c9c406aff61d404d2afe71c416ed019beb0 (patch) | |
tree | b63a67195ff9a28bbf0f5efd28d590edfe71bd5d | |
parent | ad9ebadbde4405a544e5cf32f1f5d3507a7e2dfd (diff) | |
parent | f319d32516be565718a0286f7589d66497daf60f (diff) | |
download | fpm-e92d9c9c406aff61d404d2afe71c416ed019beb0.tar.gz fpm-e92d9c9c406aff61d404d2afe71c416ed019beb0.zip |
Merge pull request #208 from LKedward/filesystem-fixes
Minor fixes: to list_files and mkdir in fpm_filesystem
-rw-r--r-- | fpm/src/fpm_filesystem.f90 | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/fpm/src/fpm_filesystem.f90 b/fpm/src/fpm_filesystem.f90 index d2096f1..4c12314 100644 --- a/fpm/src/fpm_filesystem.f90 +++ b/fpm/src/fpm_filesystem.f90 @@ -215,6 +215,8 @@ subroutine mkdir(dir) character(len=*), intent(in) :: dir integer :: stat + if (is_dir(dir)) return + select case (get_os_type()) case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD) call execute_command_line('mkdir -p ' // dir, exitstat=stat) @@ -233,6 +235,11 @@ end subroutine mkdir recursive subroutine list_files(dir, files, recurse) + ! Get file & directory names in directory `dir`. + ! + ! - File/directory names return are relative to cwd, ie. preprended with `dir` + ! - Includes files starting with `.` except current directory and parent directory + ! character(len=*), intent(in) :: dir type(string_t), allocatable, intent(out) :: files(:) logical, intent(in), optional :: recurse @@ -242,8 +249,7 @@ recursive subroutine list_files(dir, files, recurse) type(string_t), allocatable :: dir_files(:) type(string_t), allocatable :: sub_dir_files(:) - ! Using `inquire` / exists on directories works with gfortran, but not ifort - if (.not. exists(dir)) then + if (.not. is_dir(dir)) then allocate (files(0)) return end if @@ -252,7 +258,7 @@ recursive subroutine list_files(dir, files, recurse) select case (get_os_type()) case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD) - call execute_command_line('ls ' // dir // ' > ' // temp_file, & + call execute_command_line('ls -A ' // dir // ' > ' // temp_file, & exitstat=stat) case (OS_WINDOWS) call execute_command_line('dir /b ' // windows_path(dir) // ' > ' // temp_file, & |