I'm writing a little console application that needs to load its configurations from a file in a neighbored directory.
Normally is not always executed from the installation folder so first I need to recognize the installation folder and from there on build the configuration folder.
So I developed this code:
I was expecting to be able to build the configuration file path as: /playground/application_default.conf
instead it was truncated to:
app cnf pth 1: '/application_default.conf'
Path of this executable is: /playground/target/debug/playground
md pth : '/playground/target/debug/playground'
md nm : 'playground'
mndir: '/playground'
wrkdir: '/playground'
cnf dir 1: '/playground'
log dir 1: '/playground'
app cnf pth 0: '/playground'
app cnf pth 1: '/application_default.conf'
config file directory: '/playground'
config file name: 'application_default.conf'
So first I want to find the correct location of the configuration file
and second I want to resolve all unwrap()
calls.
My clear favorite is this one to get the name of the configuration file:
println!(
"config file name: '{}'",
scnfflnm.file_name().unwrap().to_str().unwrap()
);
I appreciate any suggestions on this topic.