From 8739519e1591819cab85e1d2056804d20c197dac Mon Sep 17 00:00:00 2001 From: Aloshi Date: Wed, 13 Aug 2014 18:45:26 -0500 Subject: [PATCH] Fix removeCommonPath throwing an exception when path does not exist. --- es-core/src/Util.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/es-core/src/Util.cpp b/es-core/src/Util.cpp index 1a9693bc9..198e10a82 100644 --- a/es-core/src/Util.cpp +++ b/es-core/src/Util.cpp @@ -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" 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 r = fs::canonical(relativeTo);