aboutsummaryrefslogtreecommitdiff
path: root/src/fpm_filesystem.f90
diff options
context:
space:
mode:
authorLaurence Kedward <laurence.kedward@bristol.ac.uk>2021-07-16 11:07:16 +0100
committerGitHub <noreply@github.com>2021-07-16 11:07:16 +0100
commit68937a4eae6a71b74edbf762c574cc2dc22bb2d6 (patch)
treee61837e75eeb361af0c3624a7f28169a9d06bf60 /src/fpm_filesystem.f90
parent5617e65751193afb3c88fbc6cb8a32822ff52ffa (diff)
parent87271c5a55ad6412114c4b153c1a8d0bd37156f5 (diff)
downloadfpm-68937a4eae6a71b74edbf762c574cc2dc22bb2d6.tar.gz
fpm-68937a4eae6a71b74edbf762c574cc2dc22bb2d6.zip
Merge pull request #511 from urbanjost/warn_blank_name
check name used for package, executable, test, or example
Diffstat (limited to 'src/fpm_filesystem.f90')
-rw-r--r--src/fpm_filesystem.f9032
1 files changed, 8 insertions, 24 deletions
diff --git a/src/fpm_filesystem.f90 b/src/fpm_filesystem.f90
index e6226b4..2a32b54 100644
--- a/src/fpm_filesystem.f90
+++ b/src/fpm_filesystem.f90
@@ -1,16 +1,17 @@
!> This module contains general routines for interacting with the file system
!!
module fpm_filesystem
-use,intrinsic :: iso_fortran_env, only : stdin=>input_unit, stdout=>output_unit, stderr=>error_unit
+ 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_OPENBSD
use fpm_environment, only: separator, get_env
use fpm_strings, only: f_string, replace, string_t, split
+ use fpm_error, only : fpm_stop
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
+ mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file
public :: fileopen, fileclose, filewrite, warnwrite, parent_dir
public :: which
@@ -306,8 +307,7 @@ subroutine mkdir(dir)
end select
if (stat /= 0) then
- print *, 'execute_command_line() failed'
- error stop
+ call fpm_stop(1, '*mkdir*:directory creation failed')
end if
end subroutine mkdir
@@ -344,8 +344,7 @@ recursive subroutine list_files(dir, files, recurse)
end select
if (stat /= 0) then
- print *, 'execute_command_line() failed'
- error stop
+ call fpm_stop(2,'*list_files*:directory listing failed')
end if
open (newunit=fh, file=temp_file, status='old')
@@ -556,13 +555,11 @@ character(len=256) :: message
ios=0
endif
if(ios.ne.0)then
- write(stderr,'(*(a:,1x))')&
- & '<ERROR> *filewrite*:',filename,trim(message)
lun=-1
if(present(ier))then
ier=ios
else
- stop 1
+ call fpm_stop(3,'*fileopen*:'//filename//':'//trim(message))
endif
endif
@@ -577,11 +574,10 @@ integer :: ios
if(lun.ne.-1)then
close(unit=lun,iostat=ios,iomsg=message)
if(ios.ne.0)then
- write(stderr,'(*(a:,1x))')'<ERROR> *filewrite*:',trim(message)
if(present(ier))then
ier=ios
else
- stop 2
+ call fpm_stop(4,'*fileclose*:'//trim(message))
endif
endif
endif
@@ -601,9 +597,7 @@ character(len=256) :: message
do i=1,size(filedata)
write(lun,'(a)',iostat=ios,iomsg=message)trim(filedata(i))
if(ios.ne.0)then
- write(stderr,'(*(a:,1x))')&
- & '<ERROR> *filewrite*:',filename,trim(message)
- stop 4
+ call fpm_stop(5,'*filewrite*:'//filename//':'//trim(message))
endif
enddo
endif
@@ -612,16 +606,6 @@ character(len=256) :: message
end subroutine filewrite
-!> Returns string with special characters replaced with an underscore.
-!! For now, only a hyphen is treated as a special character, but this can be
-!! expanded to other characters if needed.
-pure function to_fortran_name(string) result(res)
- character(*), intent(in) :: string
- character(len(string)) :: res
- character, parameter :: SPECIAL_CHARACTERS(*) = ['-']
- res = replace(string, SPECIAL_CHARACTERS, '_')
-end function to_fortran_name
-
function which(command) result(pathname)
!>
!!##NAME