aboutsummaryrefslogtreecommitdiffstats
path: root/src/storage/plugins
diff options
context:
space:
mode:
Diffstat (limited to '')
-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
6 files changed, 52 insertions, 50 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());
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