From 41f4391cbaf552bd060e0ef973f0f66010953a0c Mon Sep 17 00:00:00 2001 From: Peter Hatina Date: Tue, 24 Sep 2013 22:09:13 +0200 Subject: [PATCH] rewrite SMTPFileSystem::readdir() --- src/simple-mtpfs-fuse.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/simple-mtpfs-fuse.cpp b/src/simple-mtpfs-fuse.cpp index ec53458..241bcae 100644 --- a/src/simple-mtpfs-fuse.cpp +++ b/src/simple-mtpfs-fuse.cpp @@ -707,10 +707,14 @@ int SMTPFileSystem::readdir(const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *file_info) { const TypeDir *content = m_device.dirFetchContent(std::string(path)); - if (!content) - return -ENOENT; + if (!content) { + errno = ENOENT; + return -1; + } + const std::set dirs = content->dirs(); const std::set files = content->files(); + for (const TypeDir &d : dirs) { struct stat st; memset(&st, 0, sizeof(st)); @@ -718,6 +722,7 @@ int SMTPFileSystem::readdir(const char *path, void *buf, fuse_fill_dir_t filler, st.st_mode = S_IFDIR | 0775; filler(buf, d.name().c_str(), &st, 0); } + for (const TypeFile &f : files) { struct stat st; memset(&st, 0, sizeof(st)); @@ -725,6 +730,7 @@ int SMTPFileSystem::readdir(const char *path, void *buf, fuse_fill_dir_t filler, st.st_mode = S_IFREG | 0664; filler(buf, f.name().c_str(), &st, 0); } + return 0; }