aboutsummaryrefslogtreecommitdiff
path: root/src/fpm_filesystem.f90
diff options
context:
space:
mode:
authorLKedward <laurence.kedward@bristol.ac.uk>2021-06-05 14:37:40 +0100
committerLKedward <laurence.kedward@bristol.ac.uk>2021-06-05 14:37:40 +0100
commit7e9c3390b04a0fc746812abd65a574a9dd219c81 (patch)
tree66a5df663bf46aa1df7c8cf174f10902ac06f1e1 /src/fpm_filesystem.f90
parent086ae55dfa09c1924d2b54bc88ddb1827f9dcfa7 (diff)
parent845217f13a23de91021ba393ef432d68683af282 (diff)
downloadfpm-7e9c3390b04a0fc746812abd65a574a9dd219c81.tar.gz
fpm-7e9c3390b04a0fc746812abd65a574a9dd219c81.zip
Merge branch 'upstream_master' into backend-grace
Diffstat (limited to 'src/fpm_filesystem.f90')
-rw-r--r--src/fpm_filesystem.f9021
1 files changed, 15 insertions, 6 deletions
diff --git a/src/fpm_filesystem.f90 b/src/fpm_filesystem.f90
index 6acd383..c9c97dd 100644
--- a/src/fpm_filesystem.f90
+++ b/src/fpm_filesystem.f90
@@ -4,13 +4,13 @@ module fpm_filesystem
use,intrinsic :: iso_fortran_env, only : stdin=>input_unit, stdout=>output_unit, stderr=>error_unit
use fpm_environment, only: get_os_type, &
OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_WINDOWS, &
- OS_CYGWIN, OS_SOLARIS, OS_FREEBSD
+ OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD
use fpm_strings, only: f_string, replace, string_t, split
implicit none
private
public :: basename, canon_path, dirname, is_dir, join_path, number_of_rows, read_lines, list_files, env_variable, &
mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file, to_fortran_name
- public :: fileopen, fileclose, filewrite, warnwrite
+ public :: fileopen, fileclose, filewrite, warnwrite, parent_dir
integer, parameter :: LINE_BUFFER_LEN = 1000
@@ -184,6 +184,15 @@ function dirname(path) result (dir)
end function dirname
+!> Extract dirname from path
+function parent_dir(path) result (dir)
+ character(*), intent(in) :: path
+ character(:), allocatable :: dir
+
+ dir = path(1:scan(path,'/\',back=.true.)-1)
+
+end function parent_dir
+
!> test if a name matches an existing directory path
logical function is_dir(dir)
@@ -192,7 +201,7 @@ logical function is_dir(dir)
select case (get_os_type())
- case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
+ case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD)
call execute_command_line("test -d " // dir , exitstat=stat)
case (OS_WINDOWS)
@@ -214,7 +223,7 @@ function join_path(a1,a2,a3,a4,a5) result(path)
character(len=1) :: filesep
select case (get_os_type())
- case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
+ case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD)
filesep = '/'
case (OS_WINDOWS)
filesep = '\'
@@ -283,7 +292,7 @@ subroutine mkdir(dir)
if (is_dir(dir)) return
select case (get_os_type())
- case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
+ case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD)
call execute_command_line('mkdir -p ' // dir, exitstat=stat)
write (*, '(" + ",2a)') 'mkdir -p ' // dir
@@ -322,7 +331,7 @@ recursive subroutine list_files(dir, files, recurse)
allocate (temp_file, source=get_temp_filename())
select case (get_os_type())
- case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD)
+ case (OS_UNKNOWN, OS_LINUX, OS_MACOS, OS_CYGWIN, OS_SOLARIS, OS_FREEBSD, OS_OPENBSD)
call execute_command_line('ls -A ' // dir // ' > ' // temp_file, &
exitstat=stat)
case (OS_WINDOWS)