diff options
author | Max Kellermann <max@duempel.org> | 2015-03-03 20:34:02 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2015-03-03 21:41:11 +0100 |
commit | a5760670efca8ea6c4b4d425ea5e0479c760b48e (patch) | |
tree | fb427ca3919fbdd5dd59222ac1b2ab548dc8d9cd /src/fs/io/FileReader.cxx | |
parent | f04a3ec2017d63b8bb48e3d71c6502779a05321a (diff) | |
download | mpd-a5760670efca8ea6c4b4d425ea5e0479c760b48e.tar.gz mpd-a5760670efca8ea6c4b4d425ea5e0479c760b48e.tar.xz mpd-a5760670efca8ea6c4b4d425ea5e0479c760b48e.zip |
fs/io/FileReader: add method GetFileInfo()
Diffstat (limited to '')
-rw-r--r-- | src/fs/io/FileReader.cxx | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/fs/io/FileReader.cxx b/src/fs/io/FileReader.cxx index 474431ef8..e54f6f3a8 100644 --- a/src/fs/io/FileReader.cxx +++ b/src/fs/io/FileReader.cxx @@ -19,7 +19,7 @@ #include "config.h" #include "FileReader.hxx" -#include "fs/FileSystem.hxx" +#include "fs/FileInfo.hxx" #include "util/Error.hxx" #ifdef WIN32 @@ -36,6 +36,14 @@ FileReader::FileReader(Path _path, Error &error) } } +bool +FileReader::GetFileInfo(FileInfo &info, Error &error) const +{ + assert(IsDefined()); + + return ::GetFileInfo(path, info, error); +} + size_t FileReader::Read(void *data, size_t size, Error &error) { @@ -83,6 +91,19 @@ FileReader::FileReader(Path _path, Error &error) error.FormatErrno("Failed to open %s", path.c_str()); } +bool +FileReader::GetFileInfo(FileInfo &info, Error &error) const +{ + assert(IsDefined()); + + const bool success = fstat(fd.Get(), &info.st) == 0; + if (!success) + error.FormatErrno("Failed to access %s", + path.ToUTF8().c_str()); + + return success; +} + size_t FileReader::Read(void *data, size_t size, Error &error) { |