diff options
author | Max Kellermann <max@duempel.org> | 2014-10-06 21:45:40 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-10-07 06:35:53 +0200 |
commit | f0bb5b84f986798a18aea24540eb4c7c3ab972e7 (patch) | |
tree | a9674cebc2515c5ca73c10d42436e300bace3903 /src | |
parent | 07b50f6c6985581f2db397b3adfacda09deba390 (diff) | |
download | mpd-f0bb5b84f986798a18aea24540eb4c7c3ab972e7.tar.gz mpd-f0bb5b84f986798a18aea24540eb4c7c3ab972e7.tar.xz mpd-f0bb5b84f986798a18aea24540eb4c7c3ab972e7.zip |
storage/nfs: move code to Copy()
Diffstat (limited to 'src')
-rw-r--r-- | src/storage/plugins/NfsStorage.cxx | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/storage/plugins/NfsStorage.cxx b/src/storage/plugins/NfsStorage.cxx index 40625fc9a..5697dcb56 100644 --- a/src/storage/plugins/NfsStorage.cxx +++ b/src/storage/plugins/NfsStorage.cxx @@ -115,16 +115,9 @@ NfsStorage::MapToRelativeUTF8(const char *uri_utf8) const return PathTraitsUTF8::Relative(base.c_str(), uri_utf8); } -static bool -GetInfo(nfs_context *ctx, const char *path, FileInfo &info, Error &error) +static void +Copy(FileInfo &info, const struct stat &st) { - struct stat st; - int result = nfs_stat(ctx, path, &st); - if (result < 0) { - error.SetErrno(-result, "nfs_stat() failed"); - return false; - } - if (S_ISREG(st.st_mode)) info.type = FileInfo::Type::REGULAR; else if (S_ISDIR(st.st_mode)) @@ -136,6 +129,19 @@ GetInfo(nfs_context *ctx, const char *path, FileInfo &info, Error &error) info.mtime = st.st_mtime; info.device = st.st_dev; info.inode = st.st_ino; +} + +static bool +GetInfo(nfs_context *ctx, const char *path, FileInfo &info, Error &error) +{ + struct stat st; + int result = nfs_stat(ctx, path, &st); + if (result < 0) { + error.SetErrno(-result, "nfs_stat() failed"); + return false; + } + + Copy(info, st); return true; } @@ -201,13 +207,10 @@ NfsDirectoryReader::Read() return nullptr; } -bool -NfsDirectoryReader::GetInfo(gcc_unused bool follow, FileInfo &info, - gcc_unused Error &error) +static void +Copy(FileInfo &info, const struct nfsdirent &ent) { - assert(ent != nullptr); - - switch (ent->type) { + switch (ent.type) { case NF3REG: info.type = FileInfo::Type::REGULAR; break; @@ -221,10 +224,19 @@ NfsDirectoryReader::GetInfo(gcc_unused bool follow, FileInfo &info, break; } - info.size = ent->size; - info.mtime = ent->mtime.tv_sec; + info.size = ent.size; + info.mtime = ent.mtime.tv_sec; info.device = 0; - info.inode = ent->inode; + info.inode = ent.inode; +} + +bool +NfsDirectoryReader::GetInfo(gcc_unused bool follow, FileInfo &info, + gcc_unused Error &error) +{ + assert(ent != nullptr); + + Copy(info, *ent); return true; } |