diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2022-04-10 21:12:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-10 21:12:09 +0200 |
commit | 44a121615a6dc62b7277f3bd0ec2009b22530deb (patch) | |
tree | 70baeed99542749b073bbac5eb9961e104c2d05d /src | |
parent | 664f07b8a9578d4bb4e55bc61397c248b1211afa (diff) | |
parent | 34ea07a8a714fd4c8d4b4bc0606e2d536dc275d5 (diff) |
Merge pull request #306 from CfirTsabari/cfirtsabari/doesn-t-work-with-dot-101
fix: dot in config name
Diffstat (limited to 'src')
-rw-r--r-- | src/file/source/file.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/file/source/file.rs b/src/file/source/file.rs index 403f3f2..8ee5d31 100644 --- a/src/file/source/file.rs +++ b/src/file/source/file.rs @@ -27,7 +27,7 @@ impl FileSourceFile { where F: FileStoredFormat + Format + 'static, { - let mut filename = if self.name.is_absolute() { + let filename = if self.name.is_absolute() { self.name.clone() } else { env::current_dir()?.as_path().join(&self.name) @@ -59,6 +59,9 @@ impl FileSourceFile { ))) }; } + // Adding a dummy extension will make sure we will not override secondary extensions, i.e. "file.local" + // This will make the following set_extension function calls to append the extension. + let mut filename = add_dummy_extension(filename); match format_hint { Some(format) => { @@ -121,3 +124,18 @@ where }) } } + +fn add_dummy_extension(mut filename: PathBuf) -> PathBuf { + match filename.extension() { + Some(extension) => { + let mut ext = extension.to_os_string(); + ext.push("."); + ext.push("dummy"); + filename.set_extension(ext); + } + None => { + filename.set_extension("dummy"); + } + } + filename +} |