@@ -25,56 +25,56 @@ impl FileSourceFile {
25
25
where
26
26
F : FileStoredFormat + Format + ' static ,
27
27
{
28
- let filename = if self . name . is_absolute ( ) {
28
+ let path = if self . name . is_absolute ( ) {
29
29
self . name . clone ( )
30
30
} else {
31
31
env:: current_dir ( ) ?. as_path ( ) . join ( & self . name )
32
32
} ;
33
33
34
34
// First check for an _exact_ match
35
- if filename . is_file ( ) {
35
+ if path . is_file ( ) {
36
36
if let Some ( format) = format_hint {
37
- return Ok ( ( filename , Box :: new ( format) ) ) ;
37
+ return Ok ( ( path , Box :: new ( format) ) ) ;
38
38
} else {
39
- let ext = filename . extension ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
39
+ let ext = path . extension ( ) . unwrap_or_default ( ) . to_string_lossy ( ) ;
40
40
for format in FileFormat :: all ( ) {
41
41
if format. extensions ( ) . contains ( & ext. as_ref ( ) ) {
42
- return Ok ( ( filename , Box :: new ( * format) ) ) ;
42
+ return Ok ( ( path , Box :: new ( * format) ) ) ;
43
43
}
44
44
}
45
45
return Err ( Box :: new ( io:: Error :: new (
46
46
io:: ErrorKind :: NotFound ,
47
47
format ! (
48
48
"configuration file \" {}\" is not of a registered file format" ,
49
- filename . to_string_lossy( )
49
+ path . to_string_lossy( )
50
50
) ,
51
51
) ) ) ;
52
52
} ;
53
53
}
54
54
55
- let mut filename = filename ;
55
+ let mut path = path ;
56
56
// Preserve any extension-like text within the provided file stem by appending a fake extension
57
57
// which will be replaced by `set_extension()` calls (e.g. `file.local.placeholder` => `file.local.json`)
58
- if filename . extension ( ) . is_some ( ) {
59
- filename . as_mut_os_string ( ) . push ( ".placeholder" ) ;
58
+ if path . extension ( ) . is_some ( ) {
59
+ path . as_mut_os_string ( ) . push ( ".placeholder" ) ;
60
60
}
61
61
match format_hint {
62
62
Some ( format) => {
63
63
for ext in format. file_extensions ( ) {
64
- filename . set_extension ( ext) ;
64
+ path . set_extension ( ext) ;
65
65
66
- if filename . is_file ( ) {
67
- return Ok ( ( filename , Box :: new ( format) ) ) ;
66
+ if path . is_file ( ) {
67
+ return Ok ( ( path , Box :: new ( format) ) ) ;
68
68
}
69
69
}
70
70
}
71
71
None => {
72
72
for format in FileFormat :: all ( ) {
73
73
for ext in format. extensions ( ) {
74
- filename . set_extension ( ext) ;
74
+ path . set_extension ( ext) ;
75
75
76
- if filename . is_file ( ) {
77
- return Ok ( ( filename , Box :: new ( * format) ) ) ;
76
+ if path . is_file ( ) {
77
+ return Ok ( ( path , Box :: new ( * format) ) ) ;
78
78
}
79
79
}
80
80
}
0 commit comments