mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Fix removeCommonPath throwing an exception when path does not exist.
This commit is contained in:
parent
fb16dd8a91
commit
8739519e15
|
@ -103,6 +103,13 @@ fs::path resolvePath(const fs::path& path, const fs::path& relativeTo, bool allo
|
||||||
// example: removeCommonPath("/home/pi/roms/nes/foo/bar.nes", "/home/pi/roms/nes/") returns "foo/bar.nes"
|
// example: removeCommonPath("/home/pi/roms/nes/foo/bar.nes", "/home/pi/roms/nes/") returns "foo/bar.nes"
|
||||||
fs::path removeCommonPath(const fs::path& path, const fs::path& relativeTo, bool& contains)
|
fs::path removeCommonPath(const fs::path& path, const fs::path& relativeTo, bool& contains)
|
||||||
{
|
{
|
||||||
|
// if either of these doesn't exist, fs::canonical() is going to throw an error
|
||||||
|
if(!fs::exists(path) || !fs::exists(relativeTo))
|
||||||
|
{
|
||||||
|
contains = false;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
fs::path p = fs::canonical(path);
|
fs::path p = fs::canonical(path);
|
||||||
fs::path r = fs::canonical(relativeTo);
|
fs::path r = fs::canonical(relativeTo);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue