From: Mikko Rasa Date: Tue, 7 Apr 2015 11:05:12 +0000 (+0300) Subject: Include filename in errors from stat X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=d91c3450a11c097d34ceba4444758fffe815b61a;p=libs%2Fcore.git Include filename in errors from stat --- diff --git a/source/fs/unix/stat.cpp b/source/fs/unix/stat.cpp index 1ba62cd..3523633 100644 --- a/source/fs/unix/stat.cpp +++ b/source/fs/unix/stat.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include "stat.h" #include "stat_private.h" @@ -47,10 +48,11 @@ Stat Stat::stat(const Path &path) int ret = ::stat(path.str().c_str(), &st); if(ret==-1) { - if(errno==ENOENT) + int err = errno; + if(err==ENOENT) return Stat(); else - throw system_error("stat"); + throw system_error(format("stat(%s)", path), err); } return Private::from_struct_stat(st); @@ -62,10 +64,11 @@ Stat Stat::lstat(const Path &path) int ret = ::lstat(path.str().c_str(), &st); if(ret==-1) { - if(errno==ENOENT) + int err = errno; + if(err==ENOENT) return Stat(); else - throw system_error("lstat"); + throw system_error(format("lstat(%s)", path), err); } return Private::from_struct_stat(st); diff --git a/source/fs/windows/stat.cpp b/source/fs/windows/stat.cpp index 229d9e9..a1f19ef 100644 --- a/source/fs/windows/stat.cpp +++ b/source/fs/windows/stat.cpp @@ -80,7 +80,7 @@ Stat Stat::stat(const Path &path) if(err==ERROR_FILE_NOT_FOUND) return Stat(); else - throw system_error("CreateFile", err); + throw system_error(format("CreateFile(%s)", path), err); } BY_HANDLE_FILE_INFORMATION info;