@@ -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
- os_delete_dir, is_absolute_path, env_variable, get_home, execute_and_read_output, &
18
- get_dos_path
17
+ os_delete_dir, is_absolute_path, get_home, execute_and_read_output, get_dos_path
19
18
20
19
#ifndef FPM_BOOTSTRAP
21
20
interface
@@ -53,32 +52,7 @@ end function c_is_dir
53
52
54
53
contains
55
54
56
-
57
- ! > return value of environment variable
58
- subroutine env_variable (var , name )
59
- character (len= :), allocatable , intent (out ) :: var
60
- character (len=* ), intent (in ) :: name
61
- integer :: length, stat
62
-
63
- call get_environment_variable(name, length= length, status= stat)
64
- if (stat /= 0 ) return
65
-
66
- allocate (character (len= length) :: var)
67
-
68
- if (length > 0 ) then
69
- call get_environment_variable(name, var, status= stat)
70
- if (stat /= 0 ) then
71
- deallocate (var)
72
- return
73
- end if
74
- end if
75
-
76
- end subroutine env_variable
77
-
78
-
79
- ! > Extract filename from path with or without suffix.
80
- ! >
81
- ! > The suffix is included by default.
55
+ ! > Extract filename from path with/without suffix
82
56
function basename (path ,suffix ) result (base)
83
57
84
58
character (* ), intent (In ) :: path
@@ -1079,15 +1053,15 @@ function get_local_prefix(os) result(prefix)
1079
1053
character (len= :), allocatable :: home
1080
1054
1081
1055
if (os_is_unix(os)) then
1082
- call env_variable( home, " HOME" )
1083
- if (allocated ( home) ) then
1056
+ home= get_env( ' HOME' , ' ' )
1057
+ if (home /= ' ' ) then
1084
1058
prefix = join_path(home, " .local" )
1085
1059
else
1086
1060
prefix = default_prefix_unix
1087
1061
end if
1088
1062
else
1089
- call env_variable( home, " APPDATA" )
1090
- if (allocated ( home) ) then
1063
+ home= get_env( ' APPDATA' , ' ' )
1064
+ if (home /= ' ' ) then
1091
1065
prefix = join_path(home, " local" )
1092
1066
else
1093
1067
prefix = default_prefix_win
@@ -1130,14 +1104,14 @@ subroutine get_home(home, error)
1130
1104
type (error_t), allocatable , intent (out ) :: error
1131
1105
1132
1106
if (os_is_unix()) then
1133
- call env_variable( home, ' HOME' )
1134
- if (.not. allocated ( home) ) then
1107
+ home= get_env( ' HOME' , ' ' )
1108
+ if ( home == ' ' ) then
1135
1109
call fatal_error(error, " Couldn't retrieve 'HOME' variable" )
1136
1110
return
1137
1111
end if
1138
1112
else
1139
- call env_variable( home, ' USERPROFILE' )
1140
- if (.not. allocated ( home) ) then
1113
+ home= get_env( ' USERPROFILE' , ' ' )
1114
+ if ( home == ' ' ) then
1141
1115
call fatal_error(error, " Couldn't retrieve '%USERPROFILE%' variable" )
1142
1116
return
1143
1117
end if
0 commit comments