fs/io/Reader: use C++ exceptions instead of class Error

This commit is contained in:
Max Kellermann
2015-12-16 11:05:33 +01:00
parent fe60c52c70
commit e6e7d6dbd6
33 changed files with 192 additions and 334 deletions

View File

@@ -23,6 +23,7 @@
#include "check.h"
#include "Path.hxx"
#include "util/Error.hxx"
#include "system/Error.hxx"
#include <stdint.h>
@@ -63,6 +64,20 @@ class FileInfo {
#endif
public:
FileInfo() = default;
FileInfo(Path path, bool follow_symlinks=true) {
if (!GetFileInfo(path, *this, follow_symlinks)) {
#ifdef WIN32
throw FormatLastError("Failed to access %s",
path.ToUTF8().c_str());
#else
throw FormatErrno("Failed to access %s",
path.ToUTF8().c_str());
#endif
}
}
bool IsRegular() const {
#ifdef WIN32
return (data.dwFileAttributes &