From 9aae783e6877a8648d93a1e7b95459e6967f8c6b Mon Sep 17 00:00:00 2001 From: "John S. Urban" Date: Fri, 9 Jul 2021 15:05:04 -0400 Subject: check name used for package, executable, test, or example --- src/fpm_filesystem.f90 | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) (limited to 'src/fpm_filesystem.f90') diff --git a/src/fpm_filesystem.f90 b/src/fpm_filesystem.f90 index e6226b4..8f61f96 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, 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 +306,7 @@ subroutine mkdir(dir) end select if (stat /= 0) then - print *, 'execute_command_line() failed' - error stop + stop 'execute_command_line() failed' end if end subroutine mkdir @@ -344,8 +343,7 @@ recursive subroutine list_files(dir, files, recurse) end select if (stat /= 0) then - print *, 'execute_command_line() failed' - error stop + stop 'execute_command_line() failed' end if open (newunit=fh, file=temp_file, status='old') @@ -612,16 +610,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 -- cgit v1.2.3 From cca5f83be11f40dd2be86671f8ec14a429540cc9 Mon Sep 17 00:00:00 2001 From: "John S. Urban" Date: Sun, 11 Jul 2021 16:11:39 -0400 Subject: all stops via fpm_stop(1) --- src/fpm_filesystem.f90 | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'src/fpm_filesystem.f90') diff --git a/src/fpm_filesystem.f90 b/src/fpm_filesystem.f90 index 8f61f96..2a32b54 100644 --- a/src/fpm_filesystem.f90 +++ b/src/fpm_filesystem.f90 @@ -1,12 +1,13 @@ !> 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, & @@ -306,7 +307,7 @@ subroutine mkdir(dir) end select if (stat /= 0) then - stop 'execute_command_line() failed' + call fpm_stop(1, '*mkdir*:directory creation failed') end if end subroutine mkdir @@ -343,7 +344,7 @@ recursive subroutine list_files(dir, files, recurse) end select if (stat /= 0) then - stop 'execute_command_line() failed' + call fpm_stop(2,'*list_files*:directory listing failed') end if open (newunit=fh, file=temp_file, status='old') @@ -554,13 +555,11 @@ character(len=256) :: message ios=0 endif if(ios.ne.0)then - write(stderr,'(*(a:,1x))')& - & ' *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 @@ -575,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))')' *filewrite*:',trim(message) if(present(ier))then ier=ios else - stop 2 + call fpm_stop(4,'*fileclose*:'//trim(message)) endif endif endif @@ -599,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))')& - & ' *filewrite*:',filename,trim(message) - stop 4 + call fpm_stop(5,'*filewrite*:'//filename//':'//trim(message)) endif enddo endif -- cgit v1.2.3