Canonicalize some user-provided paths
These paths get displayed to users, so showing the resolved path (e.g., without "../") is clearer. Also, these paths are created if they don't exist. So if you provide something like `-exportdir=doesntexist/../real_path`, Boost will create `doesntexist/` if you create the directories before canonicalizing the path, even though it isn't used.
This commit is contained in:
parent
e9b4a1af09
commit
8bf80ae641
|
@ -318,7 +318,7 @@ const fs::path GetExportDir()
|
|||
fs::path path;
|
||||
LOCK(cs_args);
|
||||
if (mapArgs.count("-exportdir")) {
|
||||
path = fs::system_complete(mapArgs["-exportdir"]);
|
||||
path = fs::weakly_canonical(fs::system_complete(mapArgs["-exportdir"]));
|
||||
if (fs::exists(path) && !fs::is_directory(path)) {
|
||||
throw std::runtime_error(strprintf("The -exportdir '%s' already exists and is not a directory", path.string()));
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ const fs::path &GetDataDir(bool fNetSpecific)
|
|||
return path;
|
||||
|
||||
if (mapArgs.count("-datadir")) {
|
||||
path = fs::system_complete(mapArgs["-datadir"]);
|
||||
path = fs::weakly_canonical(fs::system_complete(mapArgs["-datadir"]));
|
||||
if (!fs::is_directory(path)) {
|
||||
path = "";
|
||||
return path;
|
||||
|
|
Loading…
Reference in New Issue