@@ -4,8 +4,8 @@ module fpm_settings
4
4
use fpm_environment, only: os_is_unix
5
5
use fpm_error, only: error_t, fatal_error
6
6
use fpm_toml, only: toml_table, toml_error, toml_stat, get_value, toml_load, check_keys
7
- use fpm_os, only: get_current_directory, change_directory, get_absolute_path, &
8
- convert_to_absolute_path
7
+ use fpm_os, only: get_current_directory, change_directory, get_absolute_path, convert_to_absolute_path
8
+
9
9
implicit none
10
10
private
11
11
public :: fpm_global_settings, get_global_settings, get_registry_settings, official_registry_base_url
@@ -21,7 +21,7 @@ module fpm_settings
21
21
! > Registry configs.
22
22
type (fpm_registry_settings), allocatable :: registry_settings
23
23
contains
24
- procedure :: has_custom_location, full_path
24
+ procedure :: has_custom_location, full_path, path_to_config_folder_or_empty
25
25
end type
26
26
27
27
type :: fpm_registry_settings
@@ -57,8 +57,8 @@ subroutine get_global_settings(global_settings, error)
57
57
! Use custom path to the config file if it was specified.
58
58
if (global_settings% has_custom_location()) then
59
59
! Throw error if folder doesn't exist.
60
- if (.not. exists(config_path( global_settings) )) then
61
- call fatal_error(error, " Folder not found: '" // config_path( global_settings) // " '." ); return
60
+ if (.not. exists(global_settings% path_to_config_folder )) then
61
+ call fatal_error(error, " Folder not found: '" // global_settings% path_to_config_folder // " '." ); return
62
62
end if
63
63
64
64
! Throw error if the file doesn't exist.
@@ -106,7 +106,6 @@ subroutine get_global_settings(global_settings, error)
106
106
else
107
107
call use_default_registry_settings(global_settings)
108
108
end if
109
-
110
109
end
111
110
112
111
! > Default registry settings are typically applied if the config file doesn't exist or no registry table was found in
@@ -116,7 +115,7 @@ subroutine use_default_registry_settings(global_settings)
116
115
117
116
allocate (global_settings% registry_settings)
118
117
global_settings% registry_settings% url = official_registry_base_url
119
- global_settings% registry_settings% cache_path = join_path(config_path( global_settings), &
118
+ global_settings% registry_settings% cache_path = join_path(global_settings% path_to_config_folder_or_empty( ), &
120
119
& ' dependencies' )
121
120
end
122
121
@@ -156,7 +155,7 @@ subroutine get_registry_settings(table, global_settings, error)
156
155
global_settings% registry_settings% path = path
157
156
else
158
157
! Get canonical, absolute path on both Unix and Windows.
159
- call get_absolute_path(join_path(config_path( global_settings), path), &
158
+ call get_absolute_path(join_path(global_settings% path_to_config_folder_or_empty( ), path), &
160
159
& global_settings% registry_settings% path, error)
161
160
if (allocated (error)) return
162
161
@@ -202,20 +201,20 @@ subroutine get_registry_settings(table, global_settings, error)
202
201
if (.not. exists(cache_path)) call mkdir(cache_path)
203
202
global_settings% registry_settings% cache_path = cache_path
204
203
else
205
- cache_path = join_path(config_path( global_settings), cache_path)
204
+ cache_path = join_path(global_settings% path_to_config_folder_or_empty( ), cache_path)
206
205
if (.not. exists(cache_path)) call mkdir(cache_path)
207
206
! Get canonical, absolute path on both Unix and Windows.
208
207
call get_absolute_path(cache_path, global_settings% registry_settings% cache_path, error)
209
208
if (allocated (error)) return
210
209
end if
211
210
else if (.not. allocated (path)) then
212
- global_settings% registry_settings% cache_path = join_path(config_path(global_settings), &
213
- & ' dependencies' )
211
+ global_settings% registry_settings% cache_path = &
212
+ join_path(global_settings % path_to_config_folder_or_empty(), ' dependencies' )
214
213
end if
215
214
end
216
215
217
216
! > True if the global config file is not at the default location.
218
- pure logical function has_custom_location(self)
217
+ elemental logical function has_custom_location(self)
219
218
class(fpm_global_settings), intent (in ) :: self
220
219
221
220
has_custom_location = allocated (self% path_to_config_folder) .and. allocated (self% config_file_name)
@@ -228,19 +227,18 @@ function full_path(self) result(result)
228
227
class(fpm_global_settings), intent (in ) :: self
229
228
character (len= :), allocatable :: result
230
229
231
- result = join_path(config_path( self), self% config_file_name)
230
+ result = join_path(self% path_to_config_folder_or_empty( ), self% config_file_name)
232
231
end
233
232
234
233
! > The path to the global config directory.
235
- function config_path (self )
234
+ pure function path_to_config_folder_or_empty (self )
236
235
class(fpm_global_settings), intent (in ) :: self
237
- character (len= :), allocatable :: config_path
236
+ character (len= :), allocatable :: path_to_config_folder_or_empty
238
237
239
238
if (allocated (self% path_to_config_folder)) then
240
- config_path = self% path_to_config_folder
239
+ path_to_config_folder_or_empty = self% path_to_config_folder
241
240
else
242
- config_path = " "
241
+ path_to_config_folder_or_empty = " "
243
242
end if
244
243
end
245
-
246
244
end
0 commit comments