Skip to content

Commit 8739519

Browse files
committed
Fix removeCommonPath throwing an exception when path does not exist.
1 parent fb16dd8 commit 8739519

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

es-core/src/Util.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ fs::path resolvePath(const fs::path& path, const fs::path& relativeTo, bool allo
103103
// example: removeCommonPath("/home/pi/roms/nes/foo/bar.nes", "/home/pi/roms/nes/") returns "foo/bar.nes"
104104
fs::path removeCommonPath(const fs::path& path, const fs::path& relativeTo, bool& contains)
105105
{
106+
// if either of these doesn't exist, fs::canonical() is going to throw an error
107+
if(!fs::exists(path) || !fs::exists(relativeTo))
108+
{
109+
contains = false;
110+
return path;
111+
}
112+
106113
fs::path p = fs::canonical(path);
107114
fs::path r = fs::canonical(relativeTo);
108115

0 commit comments

Comments
 (0)