Skip to content

Commit e4ee8e5

Browse files
Handle path doesn't exist in fileutl_absolute_path
Give more meaningful message when crash because path doesn't exist
1 parent 749264b commit e4ee8e5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/util/file_util.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Date: January 2012
1212
#include <cassert>
1313

1414
#include <fstream>
15+
#include <cstring>
1516
#include <cstdlib>
1617
#include <algorithm>
1718
#include <sstream>
@@ -255,6 +256,11 @@ std::string fileutl_absolute_path(std::string const &path)
255256
return std::string(&(buffer[0]));
256257
#else
257258
char *absolute = realpath(path.c_str(), nullptr);
259+
if(absolute==NULL)
260+
{
261+
std::string error=std::strerror(errno);
262+
throw std::ios::failure("Could not resolve absolute path ("+error+")");
263+
}
258264
std::string ret(absolute);
259265
free(absolute);
260266
return ret;

0 commit comments

Comments
 (0)