@@ -215,6 +215,8 @@ subroutine mkdir(dir)
215
215
character (len=* ), intent (in ) :: dir
216
216
integer :: stat
217
217
218
+ if (is_dir(dir)) return
219
+
218
220
select case (get_os_type())
219
221
case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
220
222
call execute_command_line(' mkdir -p ' // dir, exitstat= stat)
@@ -233,6 +235,11 @@ end subroutine mkdir
233
235
234
236
235
237
recursive subroutine list_files (dir , files , recurse )
238
+ ! Get file & directory names in directory `dir`.
239
+ !
240
+ ! - File/directory names return are relative to cwd, ie. preprended with `dir`
241
+ ! - Includes files starting with `.` except current directory and parent directory
242
+ !
236
243
character (len=* ), intent (in ) :: dir
237
244
type (string_t), allocatable , intent (out ) :: files(:)
238
245
logical , intent (in ), optional :: recurse
@@ -242,8 +249,7 @@ recursive subroutine list_files(dir, files, recurse)
242
249
type (string_t), allocatable :: dir_files(:)
243
250
type (string_t), allocatable :: sub_dir_files(:)
244
251
245
- ! Using `inquire` / exists on directories works with gfortran, but not ifort
246
- if (.not. exists(dir)) then
252
+ if (.not. is_dir(dir)) then
247
253
allocate (files(0 ))
248
254
return
249
255
end if
@@ -252,7 +258,7 @@ recursive subroutine list_files(dir, files, recurse)
252
258
253
259
select case (get_os_type())
254
260
case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
255
- call execute_command_line(' ls ' // dir // ' > ' // temp_file, &
261
+ call execute_command_line(' ls -A ' // dir // ' > ' // temp_file, &
256
262
exitstat= stat)
257
263
case (OS_WINDOWS)
258
264
call execute_command_line(' dir /b ' // windows_path(dir) // ' > ' // temp_file, &
0 commit comments