aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJeffrey Armstrong <jeff@approximatrix.com>2021-04-13 09:56:28 -0400
committerJeffrey Armstrong <jeff@approximatrix.com>2021-04-13 09:56:28 -0400
commit14441b7f0d6dd0a101b38a4500fe1f662ae00215 (patch)
tree32a950d3f5817335dda2783eaad5609dd6268d98 /common
parenta001a16dbb64590172677092e2a55b594c6a2f7b (diff)
downloadlevitating-14441b7f0d6dd0a101b38a4500fe1f662ae00215.tar.gz
levitating-14441b7f0d6dd0a101b38a4500fe1f662ae00215.zip
Releases page and file/dir listing works great on Linux. Should work on BSD hosts as well.
Diffstat (limited to 'common')
-rw-r--r--common/utilities.F9026
1 files changed, 19 insertions, 7 deletions
diff --git a/common/utilities.F90 b/common/utilities.F90
index 961a349..ddc0c79 100644
--- a/common/utilities.F90
+++ b/common/utilities.F90
@@ -6,6 +6,8 @@ module utilities
character, parameter::dir_sep = '/'
#endif
+ integer, parameter::DIR_LIST_STRING_LENGTH = 128
+
interface replace_field
module procedure replace_field_text
module procedure replace_field_int
@@ -276,7 +278,7 @@ contains
implicit none
character(*), intent(in)::directory
- character(1024), dimension(:), pointer::res
+ character(DIR_LIST_STRING_LENGTH), dimension(:), pointer::res
character(80)::line
character(len=:), pointer::tempfile
integer::dcount, unum, ierr, i
@@ -288,6 +290,10 @@ contains
wait=.true.)
open(newunit=unum, file=tempfile, action='read')
+
+ ! First line is "total ###"
+ read(unum, '(A)', iostat=ierr) line
+
dcount = 0
read(unum, '(A)', iostat=ierr) line
do while(ierr == 0)
@@ -303,14 +309,14 @@ contains
allocate(res(dcount))
! Now call ls, but group directories first
- call execute_command_line("ls -g "//trim(directory)//" > "//trim(tempfile), &
+ call execute_command_line("ls --group-directories-first "//trim(directory)//" > "//trim(tempfile), &
wait=.true.)
open(newunit=unum, file=tempfile, action='read')
i = 0
read(unum, '(A)', iostat=ierr) line
do while(ierr == 0 .and. i < dcount)
i = i + 1
- call combine_paths(trim(directory), trim(line), res(i))
+ res(i) = trim(line)
read(unum, '(A)', iostat=ierr) line
end do
@@ -325,7 +331,7 @@ contains
implicit none
character(*), intent(in)::directory
- character(1024), dimension(:), pointer::res
+ character(DIR_LIST_STRING_LENGTH), dimension(:), pointer::res
character(80)::line
character(len=:), pointer::tempfile
integer::dcount, total_count, unum, ierr, i
@@ -337,6 +343,10 @@ contains
wait=.true.)
open(newunit=unum, file=tempfile, action='read')
+
+ ! First line is "total ###"
+ read(unum, '(A)', iostat=ierr) line
+
dcount = 0
total_count = 0
read(unum, '(A)', iostat=ierr) line
@@ -354,16 +364,18 @@ contains
allocate(res(total_count - dcount))
! Now call ls, but group directories first
- call execute_command_line("ls -g "//trim(directory)//" > "//trim(tempfile), &
+ call execute_command_line("ls --group-directories-first "//trim(directory)//" > "//trim(tempfile), &
wait=.true.)
open(newunit=unum, file=tempfile, action='read')
+ i = 0
read(unum, '(A)', iostat=ierr) line
- do while(ierr == 0 .and. i < dcount)
+ do while(ierr == 0 .and. i <= total_count)
i = i + 1
if(i > dcount) then
- call combine_paths(trim(directory), trim(line), res(i-dcount))
+ res(i-dcount) = trim(line)
end if
+
read(unum, '(A)', iostat=ierr) line
end do