aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-09-28 13:54:39 +0200
committerMax Kellermann <max@duempel.org>2014-09-28 18:12:20 +0200
commit142d1951d25329c4ca6881d04e2f4ab82d05ac11 (patch)
tree0618a3bf4520d3b753678405934809591a65792b
parentcf06ba6d132ed29616cad89c6ee23e5334025f97 (diff)
downloadmpd-142d1951d25329c4ca6881d04e2f4ab82d05ac11.tar.gz
mpd-142d1951d25329c4ca6881d04e2f4ab82d05ac11.tar.xz
mpd-142d1951d25329c4ca6881d04e2f4ab82d05ac11.zip
storage/nfs: move code to UriToNfsPath()
Diffstat (limited to '')
-rw-r--r--src/storage/plugins/NfsStorage.cxx19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx
index 72c138feb..e8ac23ec0 100644
--- a/src/storage/plugins/NfsStorage.cxx
+++ b/src/storage/plugins/NfsStorage.cxx
@@ -79,6 +79,17 @@ public:
virtual const char *MapToRelativeUTF8(const char *uri_utf8) const override;
};
+static std::string
+UriToNfsPath(const char *uri_utf8)
+{
+ std::string path(uri_utf8);
+
+ /* libnfs paths must begin with a slash */
+ path.insert(path.begin(), '/');
+
+ return path;
+}
+
std::string
NfsStorage::MapUTF8(const char *uri_utf8) const
{
@@ -124,9 +135,7 @@ bool
NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow,
FileInfo &info, Error &error)
{
- /* libnfs paths must begin with a slash */
- std::string path(uri_utf8);
- path.insert(path.begin(), '/');
+ const std::string path = UriToNfsPath(uri_utf8);
return ::GetInfo(ctx, path.c_str(), info, error);
}
@@ -134,9 +143,7 @@ NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow,
StorageDirectoryReader *
NfsStorage::OpenDirectory(const char *uri_utf8, Error &error)
{
- /* libnfs paths must begin with a slash */
- std::string path(uri_utf8);
- path.insert(path.begin(), '/');
+ const std::string path = UriToNfsPath(uri_utf8);
nfsdir *dir;
int result = nfs_opendir(ctx, path.c_str(), &dir);