Skip to content

Commit

Permalink
Use Windows-specific commands and fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
minhqdao committed Sep 20, 2024
1 parent c1830df commit 84f36f1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 9 additions & 6 deletions src/stdlib_io_filesystem.F90
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,16 @@ subroutine list_dir(dir, files, iostat, iomsg)

stat = 0

if (.not. exists(temp_dir)) then
if (is_windows()) then
call run('mkdir '//temp_dir, stat)
if (stat /= 0) then
if (present(iostat)) iostat = stat
if (present(iomsg)) iomsg = "Failed to create temporary directory '"//temp_dir//"'."
return
end if
else
call run('mkdir -p '//temp_dir, stat)
end if

if (stat /= 0) then
if (present(iostat)) iostat = stat
if (present(iomsg)) iomsg = "Failed to create temporary directory '"//temp_dir//"'."
return
end if

call run('ls '//dir//' > '//listed_contents, stat)
Expand Down
6 changes: 5 additions & 1 deletion test/io/test_filesystem.f90
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ subroutine fs_list_dir_one_file_one_dir(error)
call test_failed(error, "Creating file 1 in directory '"//temp_list_dir//"' failed."); return
end if

call run('mkdir '//temp_list_dir//'/'//dir, iostat=stat)
if (is_windows()) then
call run('mkdir '//temp_list_dir//'\'//dir, iostat=stat)
else
call run('mkdir '//temp_list_dir//'/'//dir, iostat=stat)
end if
if (stat /= 0) then
call test_failed(error, "Creating dir in directory '"//temp_list_dir//"' failed."); return
end if
Expand Down

0 comments on commit 84f36f1

Please sign in to comment.