@@ -14,7 +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, execute_and_read_output, &
17
+ LINE_BUFFER_LEN, os_delete_dir, is_absolute_path, get_home, execute_and_read_output, &
18
18
get_dos_path
19
19
integer , parameter :: LINE_BUFFER_LEN = 32768
20
20
@@ -54,29 +54,6 @@ end function c_is_dir
54
54
55
55
contains
56
56
57
-
58
- ! > return value of environment variable
59
- subroutine env_variable (var , name )
60
- character (len= :), allocatable , intent (out ) :: var
61
- character (len=* ), intent (in ) :: name
62
- integer :: length, stat
63
-
64
- call get_environment_variable(name, length= length, status= stat)
65
- if (stat /= 0 ) return
66
-
67
- allocate (character (len= length) :: var)
68
-
69
- if (length > 0 ) then
70
- call get_environment_variable(name, var, status= stat)
71
- if (stat /= 0 ) then
72
- deallocate (var)
73
- return
74
- end if
75
- end if
76
-
77
- end subroutine env_variable
78
-
79
-
80
57
! > Extract filename from path with/without suffix
81
58
function basename (path ,suffix ) result (base)
82
59
@@ -1017,15 +994,15 @@ function get_local_prefix(os) result(prefix)
1017
994
character (len= :), allocatable :: home
1018
995
1019
996
if (os_is_unix(os)) then
1020
- call env_variable( home, " HOME" )
1021
- if (allocated ( home) ) then
997
+ home= get_env( ' HOME' , ' ' )
998
+ if (home /= ' ' ) then
1022
999
prefix = join_path(home, " .local" )
1023
1000
else
1024
1001
prefix = default_prefix_unix
1025
1002
end if
1026
1003
else
1027
- call env_variable( home, " APPDATA" )
1028
- if (allocated ( home) ) then
1004
+ home= get_env( ' APPDATA' , ' ' )
1005
+ if (home /= ' ' ) then
1029
1006
prefix = join_path(home, " local" )
1030
1007
else
1031
1008
prefix = default_prefix_win
@@ -1068,14 +1045,14 @@ subroutine get_home(home, error)
1068
1045
type (error_t), allocatable , intent (out ) :: error
1069
1046
1070
1047
if (os_is_unix()) then
1071
- call env_variable( home, ' HOME' )
1072
- if (.not. allocated ( home) ) then
1048
+ home= get_env( ' HOME' , ' ' )
1049
+ if ( home == ' ' ) then
1073
1050
call fatal_error(error, " Couldn't retrieve 'HOME' variable" )
1074
1051
return
1075
1052
end if
1076
1053
else
1077
- call env_variable( home, ' USERPROFILE' )
1078
- if (.not. allocated ( home) ) then
1054
+ home= get_env( ' USERPROFILE' , ' ' )
1055
+ if ( home == ' ' ) then
1079
1056
call fatal_error(error, " Couldn't retrieve '%USERPROFILE%' variable" )
1080
1057
return
1081
1058
end if
0 commit comments