@@ -14,8 +14,7 @@ module fpm_filesystem
14
14
public :: basename, canon_path, dirname, is_dir, join_path, number_of_rows, list_files, get_local_prefix, &
15
15
mkdir, exists, get_temp_filename, windows_path, unix_path, getline, delete_file, fileopen, fileclose, &
16
16
filewrite, warnwrite, parent_dir, is_hidden_file, read_lines, read_lines_expanded, which, run, &
17
- LINE_BUFFER_LEN, os_delete_dir, is_absolute_path, env_variable, get_home, get_tmp_directory, &
18
- execute_and_read_output
17
+ LINE_BUFFER_LEN, os_delete_dir, is_absolute_path, env_variable, get_home, execute_and_read_output
19
18
integer , parameter :: LINE_BUFFER_LEN = 1000
20
19
21
20
#ifndef FPM_BOOTSTRAP
@@ -1033,21 +1032,15 @@ subroutine execute_and_read_output(cmd, output, error, exitstat)
1033
1032
integer , intent (out ), optional :: exitstat
1034
1033
1035
1034
integer :: cmdstat, unit, stat = 0
1036
- character (len= :), allocatable :: cmdmsg, tmp_path
1035
+ character (len= :), allocatable :: cmdmsg, tmp_file
1037
1036
character (len= 1000 ) :: output_line
1038
1037
1039
- call get_tmp_directory(tmp_path, error)
1040
- if (allocated (error)) return
1038
+ tmp_file = get_temp_filename()
1041
1039
1042
- if (.not. exists(tmp_path)) call mkdir(tmp_path)
1043
- tmp_path = join_path(tmp_path, ' command_line_output' )
1044
- call delete_file(tmp_path)
1045
- call filewrite(tmp_path, [' ' ])
1040
+ call execute_command_line(cmd// ' > ' // tmp_file, exitstat= exitstat, cmdstat= cmdstat)
1041
+ if (cmdstat /= 0 ) call fatal_error(error, ' *run*: ' // " Command failed: '" // cmd// " '. Message: '" // trim (cmdmsg)// " '." )
1046
1042
1047
- call execute_command_line(cmd// ' > ' // tmp_path, exitstat= exitstat, cmdstat= cmdstat)
1048
- if (cmdstat /= 0 ) call fpm_stop(1 ,' *run*: ' // " Command failed: '" // cmd// " '. Message: '" // trim (cmdmsg)// " '." )
1049
-
1050
- open (unit, file= tmp_path, action= ' read' , status= ' old' )
1043
+ open (newunit= unit, file= tmp_file, action= ' read' , status= ' old' )
1051
1044
output = ' '
1052
1045
do
1053
1046
read (unit, * , iostat= stat) output_line
@@ -1056,30 +1049,4 @@ subroutine execute_and_read_output(cmd, output, error, exitstat)
1056
1049
end do
1057
1050
close (unit, status= ' delete' )
1058
1051
end
1059
-
1060
- ! > Get system-dependent tmp directory.
1061
- subroutine get_tmp_directory (tmp_dir , error )
1062
- ! > System-dependant tmp directory.
1063
- character (len= :), allocatable , intent (out ) :: tmp_dir
1064
- ! > Error to handle.
1065
- type (error_t), allocatable , intent (out ) :: error
1066
-
1067
- tmp_dir = get_env(' TMPDIR' , ' ' )
1068
- if (tmp_dir /= ' ' ) then
1069
- tmp_dir = tmp_dir// ' fpm' ; return
1070
- end if
1071
-
1072
- tmp_dir = get_env(' TMP' , ' ' )
1073
- if (tmp_dir /= ' ' ) then
1074
- tmp_dir = tmp_dir// ' fpm' ; return
1075
- end if
1076
-
1077
- tmp_dir = get_env(' TEMP' , ' ' )
1078
- if (tmp_dir /= ' ' ) then
1079
- tmp_dir = tmp_dir// ' fpm' ; return
1080
- end if
1081
-
1082
- call fatal_error(error, " Couldn't determine system temporary directory." )
1083
- end
1084
-
1085
1052
end module fpm_filesystem
0 commit comments