aboutsummaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-02-28 20:42:50 +0100
committerMax Kellermann <max@duempel.org>2015-02-28 23:00:26 +0100
commit90a61b6babe3528efd982511790057e1e1e39b81 (patch)
treecae3a8072a056118865a988042e1f1269d11e277 /src/storage
parent00583bc4a8357cf43930151650dc058225675403 (diff)
downloadmpd-90a61b6babe3528efd982511790057e1e1e39b81.tar.gz
mpd-90a61b6babe3528efd982511790057e1e1e39b81.tar.xz
mpd-90a61b6babe3528efd982511790057e1e1e39b81.zip
fs/FileInfo: new library providing GetFileInfo()
Replaces StatFile(), with a portable data object.
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/plugins/LocalStorage.cxx27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx
index 484c9c6db..d1584a316 100644
--- a/src/storage/plugins/LocalStorage.cxx
+++ b/src/storage/plugins/LocalStorage.cxx
@@ -23,7 +23,7 @@
#include "storage/StorageInterface.hxx"
#include "storage/FileInfo.hxx"
#include "util/Error.hxx"
-#include "fs/FileSystem.hxx"
+#include "fs/FileInfo.hxx"
#include "fs/AllocatedPath.hxx"
#include "fs/DirectoryReader.hxx"
@@ -81,26 +81,25 @@ private:
static bool
Stat(Path path, bool follow, StorageFileInfo &info, Error &error)
{
- struct stat st;
- if (!StatFile(path, st, follow)) {
- error.SetErrno();
-
- const auto path_utf8 = path.ToUTF8();
- error.FormatPrefix("Failed to stat %s: ", path_utf8.c_str());
+ FileInfo src;
+ if (!GetFileInfo(path, src, follow, error))
return false;
- }
- if (S_ISREG(st.st_mode))
+ if (src.IsRegular())
info.type = StorageFileInfo::Type::REGULAR;
- else if (S_ISDIR(st.st_mode))
+ else if (src.IsDirectory())
info.type = StorageFileInfo::Type::DIRECTORY;
else
info.type = StorageFileInfo::Type::OTHER;
- info.size = st.st_size;
- info.mtime = st.st_mtime;
- info.device = st.st_dev;
- info.inode = st.st_ino;
+ info.size = src.GetSize();
+ info.mtime = src.GetModificationTime();
+#ifdef WIN32
+ info.device = info.inode = 0;
+#else
+ info.device = src.GetDevice();
+ info.inode = src.GetInode();
+#endif
return true;
}