diff options
Diffstat (limited to 'src/storage/plugins/LocalStorage.cxx')
-rw-r--r-- | src/storage/plugins/LocalStorage.cxx | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/storage/plugins/LocalStorage.cxx b/src/storage/plugins/LocalStorage.cxx index b965ceea8..83903ec81 100644 --- a/src/storage/plugins/LocalStorage.cxx +++ b/src/storage/plugins/LocalStorage.cxx @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2014 The Music Player Daemon Project + * Copyright (C) 2003-2015 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -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" @@ -46,7 +46,8 @@ public: /* virtual methods from class StorageDirectoryReader */ const char *Read() override; - bool GetInfo(bool follow, FileInfo &info, Error &error) override; + bool GetInfo(bool follow, StorageFileInfo &info, + Error &error) override; }; class LocalStorage final : public Storage { @@ -61,7 +62,7 @@ public: } /* virtual methods from class Storage */ - bool GetInfo(const char *uri_utf8, bool follow, FileInfo &info, + bool GetInfo(const char *uri_utf8, bool follow, StorageFileInfo &info, Error &error) override; StorageDirectoryReader *OpenDirectory(const char *uri_utf8, @@ -78,28 +79,27 @@ private: }; static bool -Stat(Path path, bool follow, FileInfo &info, Error &error) +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)) - info.type = FileInfo::Type::REGULAR; - else if (S_ISDIR(st.st_mode)) - info.type = FileInfo::Type::DIRECTORY; + if (src.IsRegular()) + info.type = StorageFileInfo::Type::REGULAR; + else if (src.IsDirectory()) + info.type = StorageFileInfo::Type::DIRECTORY; else - info.type = FileInfo::Type::OTHER; - - info.size = st.st_size; - info.mtime = st.st_mtime; - info.device = st.st_dev; - info.inode = st.st_ino; + info.type = StorageFileInfo::Type::OTHER; + + 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; } @@ -142,7 +142,7 @@ LocalStorage::MapToRelativeUTF8(const char *uri_utf8) const } bool -LocalStorage::GetInfo(const char *uri_utf8, bool follow, FileInfo &info, +LocalStorage::GetInfo(const char *uri_utf8, bool follow, StorageFileInfo &info, Error &error) { AllocatedPath path_fs = MapFS(uri_utf8, error); @@ -172,7 +172,7 @@ LocalStorage::OpenDirectory(const char *uri_utf8, Error &error) gcc_pure static bool -SkipNameFS(const char *name_fs) +SkipNameFS(PathTraitsFS::const_pointer name_fs) { return name_fs[0] == '.' && (name_fs[1] == 0 || @@ -198,7 +198,7 @@ LocalDirectoryReader::Read() } bool -LocalDirectoryReader::GetInfo(bool follow, FileInfo &info, Error &error) +LocalDirectoryReader::GetInfo(bool follow, StorageFileInfo &info, Error &error) { const AllocatedPath path_fs = AllocatedPath::Build(base_fs, reader.GetEntry()); |