Commit 142d1951 authored by Max Kellermann's avatar Max Kellermann

storage/nfs: move code to UriToNfsPath()

parent cf06ba6d
...@@ -79,6 +79,17 @@ public: ...@@ -79,6 +79,17 @@ public:
virtual const char *MapToRelativeUTF8(const char *uri_utf8) const override; 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 std::string
NfsStorage::MapUTF8(const char *uri_utf8) const NfsStorage::MapUTF8(const char *uri_utf8) const
{ {
...@@ -124,9 +135,7 @@ bool ...@@ -124,9 +135,7 @@ bool
NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow, NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow,
FileInfo &info, Error &error) FileInfo &info, Error &error)
{ {
/* libnfs paths must begin with a slash */ const std::string path = UriToNfsPath(uri_utf8);
std::string path(uri_utf8);
path.insert(path.begin(), '/');
return ::GetInfo(ctx, path.c_str(), info, error); return ::GetInfo(ctx, path.c_str(), info, error);
} }
...@@ -134,9 +143,7 @@ NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow, ...@@ -134,9 +143,7 @@ NfsStorage::GetInfo(const char *uri_utf8, gcc_unused bool follow,
StorageDirectoryReader * StorageDirectoryReader *
NfsStorage::OpenDirectory(const char *uri_utf8, Error &error) NfsStorage::OpenDirectory(const char *uri_utf8, Error &error)
{ {
/* libnfs paths must begin with a slash */ const std::string path = UriToNfsPath(uri_utf8);
std::string path(uri_utf8);
path.insert(path.begin(), '/');
nfsdir *dir; nfsdir *dir;
int result = nfs_opendir(ctx, path.c_str(), &dir); int result = nfs_opendir(ctx, path.c_str(), &dir);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment