aboutsummaryrefslogtreecommitdiff
path: root/src/fpm_filesystem.f90
diff options
context:
space:
mode:
authorLaurence Kedward <laurence.kedward@bristol.ac.uk>2021-06-05 13:35:36 +0100
committerGitHub <noreply@github.com>2021-06-05 13:35:36 +0100
commit845217f13a23de91021ba393ef432d68683af282 (patch)
treecd452c22726cde71ad1796c105a207ba4258accc /src/fpm_filesystem.f90
parente0e6afe457ef717b04dd16bfbd1a47e6ed78f28b (diff)
parentf6eed99634609851afe1af9d1c44412d966381fe (diff)
downloadfpm-845217f13a23de91021ba393ef432d68683af282.tar.gz
fpm-845217f13a23de91021ba393ef432d68683af282.zip
Merge pull request #483 from awvwgk/working-directory
Allow fpm to change the working directory
Diffstat (limited to 'src/fpm_filesystem.f90')
-rw-r--r--src/fpm_filesystem.f9011
1 files changed, 10 insertions, 1 deletions
diff --git a/src/fpm_filesystem.f90 b/src/fpm_filesystem.f90
index 28c3b33..c9c97dd 100644
--- a/src/fpm_filesystem.f90
+++ b/src/fpm_filesystem.f90
@@ -10,7 +10,7 @@ use,intrinsic :: iso_fortran_env, only : stdin=>input_unit, stdout=>output_unit,
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)