aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndřej Čertík <ondrej@certik.us>2020-07-22 14:23:54 -0600
committerOndřej Čertík <ondrej@certik.us>2020-07-22 15:29:58 -0600
commitc82579b3e245e91ddec40815c059c7b432d5ee6a (patch)
tree5cc37d4f5197fb606641500a4dc5e4748a5fc7a6
parentfc03a11ebd76a089fc5191ac0fa064e87b17d0ff (diff)
downloadfpm-c82579b3e245e91ddec40815c059c7b432d5ee6a.tar.gz
fpm-c82579b3e245e91ddec40815c059c7b432d5ee6a.zip
Add a check for directory
-rw-r--r--fpm/src/fpm.f9012
1 files changed, 7 insertions, 5 deletions
diff --git a/fpm/src/fpm.f90 b/fpm/src/fpm.f90
index bf99641..45d8782 100644
--- a/fpm/src/fpm.f90
+++ b/fpm/src/fpm.f90
@@ -78,9 +78,13 @@ character(len=*), intent(in) :: dir
type(string_t), allocatable, intent(out) :: files(:)
character(len=100) :: filename
integer :: stat, u, i
+! Using `inquire` / exists on directories works with gfortran, but not ifort
+if (.not. exists(dir)) then
+ allocate(files(0))
+ return
+end if
select case (get_os_type())
case (OS_LINUX)
- ! TODO: add `dir` into the `ls` command here:
call execute_command_line("ls " // dir // " > fpm_ls.out", exitstat=stat)
case (OS_MACOS)
print *, "macOS not supported yet"
@@ -90,10 +94,8 @@ select case (get_os_type())
error stop
end select
if (stat /= 0) then
- print *, "execute_command_line() failed, but continuing"
- ! Not erroring out here, as sometimes the `dir` might not exist
- allocate(files(0))
- return
+ print *, "execute_command_line() failed"
+ error stop
end if
open(newunit=u, file="fpm_ls.out", status="old")
allocate(files(number_of_rows(u)))