X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=common%2Ffilesystem.cpp;h=877ac7ca68f6c8310d2488d1c83ad16bf2549d7f;hb=435e4ef97b2d1dc2826d2ad1fde071cf7216dbc2;hp=41869ad0427a48c9268a387824bf60be23001aa3;hpb=15fc7c0f83512dceb97a7401ac34c09e52e40be4;p=casparcg diff --git a/common/filesystem.cpp b/common/filesystem.cpp index 41869ad04..877ac7ca6 100644 --- a/common/filesystem.cpp +++ b/common/filesystem.cpp @@ -22,6 +22,7 @@ #include "stdafx.h" #include "filesystem.h" +#include "except.h" #include #include @@ -32,9 +33,11 @@ boost::filesystem::path get_relative( const boost::filesystem::path& file, const boost::filesystem::path& relative_to) { - auto result = file.filename(); + auto result = file.filename(); + auto current_path = file; - boost::filesystem::path current_path = file; + if (boost::filesystem::equivalent(current_path, relative_to)) + return L""; while (true) { @@ -44,7 +47,7 @@ boost::filesystem::path get_relative( break; if (current_path.empty()) - throw std::runtime_error("File not relative to folder"); + CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("File " + file.string() + " not relative to folder " + relative_to.string())); result = current_path.filename() / result; }