aboutsummaryrefslogtreecommitdiffstats
path: root/src/storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/storage')
-rw-r--r--src/storage/CompositeStorage.cxx14
-rw-r--r--src/storage/CompositeStorage.hxx4
-rw-r--r--src/storage/Configured.cxx8
-rw-r--r--src/storage/Configured.hxx2
-rw-r--r--src/storage/FileInfo.hxx4
-rw-r--r--src/storage/MemoryDirectoryReader.cxx5
-rw-r--r--src/storage/MemoryDirectoryReader.hxx7
-rw-r--r--src/storage/Registry.cxx2
-rw-r--r--src/storage/Registry.hxx2
-rw-r--r--src/storage/StorageInterface.cxx2
-rw-r--r--src/storage/StorageInterface.hxx10
-rw-r--r--src/storage/StoragePlugin.hxx2
-rw-r--r--src/storage/plugins/LocalStorage.cxx50
-rw-r--r--src/storage/plugins/LocalStorage.hxx2
-rw-r--r--src/storage/plugins/NfsStorage.cxx26
-rw-r--r--src/storage/plugins/NfsStorage.hxx2
-rw-r--r--src/storage/plugins/SmbclientStorage.cxx20
-rw-r--r--src/storage/plugins/SmbclientStorage.hxx2
18 files changed, 85 insertions, 79 deletions
diff --git a/src/storage/CompositeStorage.cxx b/src/storage/CompositeStorage.cxx
index 89a2fc756..10a478c0d 100644
--- a/src/storage/CompositeStorage.cxx
+++ b/src/storage/CompositeStorage.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
@@ -56,7 +56,7 @@ 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;
};
const char *
@@ -81,7 +81,7 @@ CompositeDirectoryReader::Read()
}
bool
-CompositeDirectoryReader::GetInfo(bool follow, FileInfo &info,
+CompositeDirectoryReader::GetInfo(bool follow, StorageFileInfo &info,
Error &error)
{
if (other != nullptr)
@@ -89,7 +89,7 @@ CompositeDirectoryReader::GetInfo(bool follow, FileInfo &info,
assert(current != names.end());
- info.type = FileInfo::Type::DIRECTORY;
+ info.type = StorageFileInfo::Type::DIRECTORY;
info.mtime = 0;
info.device = 0;
info.inode = 0;
@@ -137,7 +137,7 @@ CompositeStorage::Directory::Make(const char *uri)
Directory *directory = this;
while (*uri != 0) {
const std::string name = NextSegment(uri);
-#if defined(__clang__) || GCC_CHECK_VERSION(4,8)
+#if CLANG_OR_GCC_VERSION(4,8)
auto i = directory->children.emplace(std::move(name),
Directory());
#else
@@ -275,7 +275,7 @@ CompositeStorage::FindStorage(const char *uri, Error &error) const
}
bool
-CompositeStorage::GetInfo(const char *uri, bool follow, FileInfo &info,
+CompositeStorage::GetInfo(const char *uri, bool follow, StorageFileInfo &info,
Error &error)
{
const ScopeLock protect(mutex);
@@ -288,7 +288,7 @@ CompositeStorage::GetInfo(const char *uri, bool follow, FileInfo &info,
const Directory *directory = f.directory->Find(f.uri);
if (directory != nullptr) {
error.Clear();
- info.type = FileInfo::Type::DIRECTORY;
+ info.type = StorageFileInfo::Type::DIRECTORY;
info.mtime = 0;
info.device = 0;
info.inode = 0;
diff --git a/src/storage/CompositeStorage.hxx b/src/storage/CompositeStorage.hxx
index c3695c79d..08717edef 100644
--- a/src/storage/CompositeStorage.hxx
+++ b/src/storage/CompositeStorage.hxx
@@ -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
@@ -122,7 +122,7 @@ public:
bool Unmount(const char *uri);
/* virtual methods from class Storage */
- bool GetInfo(const char *uri, bool follow, FileInfo &info,
+ bool GetInfo(const char *uri, bool follow, StorageFileInfo &info,
Error &error) override;
StorageDirectoryReader *OpenDirectory(const char *uri,
diff --git a/src/storage/Configured.cxx b/src/storage/Configured.cxx
index 41541673b..d3a55eab8 100644
--- a/src/storage/Configured.cxx
+++ b/src/storage/Configured.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
@@ -44,7 +44,7 @@ CreateConfiguredStorageUri(EventLoop &event_loop, const char *uri,
static AllocatedPath
GetConfiguredMusicDirectory(Error &error)
{
- AllocatedPath path = config_get_path(CONF_MUSIC_DIR, error);
+ AllocatedPath path = config_get_path(ConfigOption::MUSIC_DIR, error);
if (path.IsNull() && !error.IsDefined())
path = GetUserMusicDir();
@@ -68,7 +68,7 @@ CreateConfiguredStorage(EventLoop &event_loop, Error &error)
{
assert(!error.IsDefined());
- auto uri = config_get_string(CONF_MUSIC_DIR, nullptr);
+ auto uri = config_get_string(ConfigOption::MUSIC_DIR);
if (uri != nullptr && uri_has_scheme(uri))
return CreateConfiguredStorageUri(event_loop, uri, error);
@@ -78,5 +78,5 @@ CreateConfiguredStorage(EventLoop &event_loop, Error &error)
bool
IsStorageConfigured()
{
- return config_get_string(CONF_MUSIC_DIR, nullptr) != nullptr;
+ return config_get_string(ConfigOption::MUSIC_DIR) != nullptr;
}
diff --git a/src/storage/Configured.hxx b/src/storage/Configured.hxx
index 828a192c3..6769da5ff 100644
--- a/src/storage/Configured.hxx
+++ b/src/storage/Configured.hxx
@@ -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
diff --git a/src/storage/FileInfo.hxx b/src/storage/FileInfo.hxx
index 8dd152c0a..4ba842811 100644
--- a/src/storage/FileInfo.hxx
+++ b/src/storage/FileInfo.hxx
@@ -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
@@ -25,7 +25,7 @@
#include <time.h>
#include <stdint.h>
-struct FileInfo {
+struct StorageFileInfo {
enum class Type : uint8_t {
OTHER,
REGULAR,
diff --git a/src/storage/MemoryDirectoryReader.cxx b/src/storage/MemoryDirectoryReader.cxx
index 160836b1a..e6875435c 100644
--- a/src/storage/MemoryDirectoryReader.cxx
+++ b/src/storage/MemoryDirectoryReader.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
@@ -37,7 +37,8 @@ MemoryStorageDirectoryReader::Read()
}
bool
-MemoryStorageDirectoryReader::GetInfo(gcc_unused bool follow, FileInfo &info,
+MemoryStorageDirectoryReader::GetInfo(gcc_unused bool follow,
+ StorageFileInfo &info,
gcc_unused Error &error)
{
assert(!first);
diff --git a/src/storage/MemoryDirectoryReader.hxx b/src/storage/MemoryDirectoryReader.hxx
index 1345082cb..69299d1d4 100644
--- a/src/storage/MemoryDirectoryReader.hxx
+++ b/src/storage/MemoryDirectoryReader.hxx
@@ -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
@@ -36,7 +36,7 @@ public:
struct Entry {
std::string name;
- FileInfo info;
+ StorageFileInfo info;
template<typename N>
explicit Entry(N &&_name):name(std::forward<N>(_name)) {}
@@ -61,7 +61,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;
};
#endif
diff --git a/src/storage/Registry.cxx b/src/storage/Registry.cxx
index d8e273fd5..a59ec01aa 100644
--- a/src/storage/Registry.cxx
+++ b/src/storage/Registry.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
diff --git a/src/storage/Registry.hxx b/src/storage/Registry.hxx
index cb3a78f11..8d7828865 100644
--- a/src/storage/Registry.hxx
+++ b/src/storage/Registry.hxx
@@ -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
diff --git a/src/storage/StorageInterface.cxx b/src/storage/StorageInterface.cxx
index 93c50a8ac..79f0815d7 100644
--- a/src/storage/StorageInterface.cxx
+++ b/src/storage/StorageInterface.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
diff --git a/src/storage/StorageInterface.hxx b/src/storage/StorageInterface.hxx
index 4484815bc..4435bbf91 100644
--- a/src/storage/StorageInterface.hxx
+++ b/src/storage/StorageInterface.hxx
@@ -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
@@ -25,7 +25,7 @@
#include <string>
-struct FileInfo;
+struct StorageFileInfo;
class AllocatedPath;
class Error;
@@ -36,7 +36,8 @@ public:
virtual ~StorageDirectoryReader() {}
virtual const char *Read() = 0;
- virtual bool GetInfo(bool follow, FileInfo &info, Error &error) = 0;
+ virtual bool GetInfo(bool follow, StorageFileInfo &info,
+ Error &error) = 0;
};
class Storage {
@@ -45,7 +46,8 @@ public:
Storage(const Storage &) = delete;
virtual ~Storage() {}
- virtual bool GetInfo(const char *uri_utf8, bool follow, FileInfo &info,
+ virtual bool GetInfo(const char *uri_utf8, bool follow,
+ StorageFileInfo &info,
Error &error) = 0;
virtual StorageDirectoryReader *OpenDirectory(const char *uri_utf8,
diff --git a/src/storage/StoragePlugin.hxx b/src/storage/StoragePlugin.hxx
index 15f431105..962963d2f 100644
--- a/src/storage/StoragePlugin.hxx
+++ b/src/storage/StoragePlugin.hxx
@@ -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
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());
diff --git a/src/storage/plugins/LocalStorage.hxx b/src/storage/plugins/LocalStorage.hxx
index 7295d38e7..ea6bc357c 100644
--- a/src/storage/plugins/LocalStorage.hxx
+++ b/src/storage/plugins/LocalStorage.hxx
@@ -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
diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx
index a1f079e2c..fc4fd5c07 100644
--- a/src/storage/plugins/NfsStorage.cxx
+++ b/src/storage/plugins/NfsStorage.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
@@ -84,7 +84,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,
@@ -245,14 +245,14 @@ NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const
}
static void
-Copy(FileInfo &info, const struct stat &st)
+Copy(StorageFileInfo &info, const struct stat &st)
{
if (S_ISREG(st.st_mode))
- info.type = FileInfo::Type::REGULAR;
+ info.type = StorageFileInfo::Type::REGULAR;
else if (S_ISDIR(st.st_mode))
- info.type = FileInfo::Type::DIRECTORY;
+ info.type = StorageFileInfo::Type::DIRECTORY;
else
- info.type = FileInfo::Type::OTHER;
+ info.type = StorageFileInfo::Type::OTHER;
info.size = st.st_size;
info.mtime = st.st_mtime;
@@ -262,11 +262,11 @@ Copy(FileInfo &info, const struct stat &st)
class NfsGetInfoOperation final : public BlockingNfsOperation {
const char *const path;
- FileInfo &info;
+ StorageFileInfo &info;
public:
NfsGetInfoOperation(NfsConnection &_connection, const char *_path,
- FileInfo &_info)
+ StorageFileInfo &_info)
:BlockingNfsOperation(_connection), path(_path), info(_info) {}
protected:
@@ -281,7 +281,7 @@ protected:
bool
NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow,
- FileInfo &info, Error &error)
+ StorageFileInfo &info, Error &error)
{
const std::string path = UriToNfsPath(uri_utf8, error);
if (path.empty())
@@ -304,19 +304,19 @@ SkipNameFS(const char *name)
}
static void
-Copy(FileInfo &info, const struct nfsdirent &ent)
+Copy(StorageFileInfo &info, const struct nfsdirent &ent)
{
switch (ent.type) {
case NF3REG:
- info.type = FileInfo::Type::REGULAR;
+ info.type = StorageFileInfo::Type::REGULAR;
break;
case NF3DIR:
- info.type = FileInfo::Type::DIRECTORY;
+ info.type = StorageFileInfo::Type::DIRECTORY;
break;
default:
- info.type = FileInfo::Type::OTHER;
+ info.type = StorageFileInfo::Type::OTHER;
break;
}
diff --git a/src/storage/plugins/NfsStorage.hxx b/src/storage/plugins/NfsStorage.hxx
index f7e18effc..bc757cf8c 100644
--- a/src/storage/plugins/NfsStorage.hxx
+++ b/src/storage/plugins/NfsStorage.hxx
@@ -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
diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx
index 70a6e16bb..84b212cd1 100644
--- a/src/storage/plugins/SmbclientStorage.cxx
+++ b/src/storage/plugins/SmbclientStorage.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
@@ -44,7 +44,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 SmbclientStorage final : public Storage {
@@ -63,7 +64,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,
@@ -92,7 +93,7 @@ SmbclientStorage::MapToRelativeUTF8(const char *uri_utf8) const
}
static bool
-GetInfo(const char *path, FileInfo &info, Error &error)
+GetInfo(const char *path, StorageFileInfo &info, Error &error)
{
struct stat st;
smbclient_mutex.lock();
@@ -104,11 +105,11 @@ GetInfo(const char *path, FileInfo &info, Error &error)
}
if (S_ISREG(st.st_mode))
- info.type = FileInfo::Type::REGULAR;
+ info.type = StorageFileInfo::Type::REGULAR;
else if (S_ISDIR(st.st_mode))
- info.type = FileInfo::Type::DIRECTORY;
+ info.type = StorageFileInfo::Type::DIRECTORY;
else
- info.type = FileInfo::Type::OTHER;
+ info.type = StorageFileInfo::Type::OTHER;
info.size = st.st_size;
info.mtime = st.st_mtime;
@@ -119,7 +120,7 @@ GetInfo(const char *path, FileInfo &info, Error &error)
bool
SmbclientStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow,
- FileInfo &info, Error &error)
+ StorageFileInfo &info, Error &error)
{
const std::string mapped = MapUTF8(uri_utf8);
return ::GetInfo(mapped.c_str(), info, error);
@@ -172,7 +173,8 @@ SmbclientDirectoryReader::Read()
}
bool
-SmbclientDirectoryReader::GetInfo(gcc_unused bool follow, FileInfo &info,
+SmbclientDirectoryReader::GetInfo(gcc_unused bool follow,
+ StorageFileInfo &info,
Error &error)
{
const std::string path = PathTraitsUTF8::Build(base.c_str(), name);
diff --git a/src/storage/plugins/SmbclientStorage.hxx b/src/storage/plugins/SmbclientStorage.hxx
index 7c198d920..dd047f97e 100644
--- a/src/storage/plugins/SmbclientStorage.hxx
+++ b/src/storage/plugins/SmbclientStorage.hxx
@@ -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