cppfs  1.2.0.5b71c2c98fb9
Cross-platform C++ file system library supporting multiple backends (Local-FS, SSH)
posix/LocalFileIterator.h
Go to the documentation of this file.
1 
2 #pragma once
3 
4 
5 #include <memory>
6 #include <dirent.h>
7 #include <sys/stat.h>
8 
10 
11 
12 namespace cppfs
13 {
14 
15 
16 class LocalFileSystem;
17 
18 
24 {
25 public:
35  LocalFileIterator(std::shared_ptr<LocalFileSystem> fs, const std::string & path);
36 
46  LocalFileIterator(std::shared_ptr<LocalFileSystem> fs, std::string && path);
47 
52  virtual ~LocalFileIterator();
53 
54  // Virtual AbstractFileIteratorBackend functions
55  virtual std::unique_ptr<AbstractFileIteratorBackend> clone() const override;
56  virtual AbstractFileSystem * fs() const override;
57  virtual bool valid() const override;
58  virtual std::string path() const override;
59  virtual int index() const override;
60  virtual std::string name() const override;
61  virtual void next() override;
62 
63 
64 protected:
65  void readNextEntry();
66 
67 
68 protected:
69  std::shared_ptr<LocalFileSystem> m_fs;
70  std::string m_path;
71  DIR * m_dir;
72  struct dirent * m_entry;
73  int m_index;
74 };
75 
76 
77 } // namespace cppfs
DIR * m_dir
Directory handle.
Definition: posix/LocalFileIterator.h:71
File iterator for the local file system.
Definition: posix/LocalFileIterator.h:23
struct dirent * m_entry
Current directory entry.
Definition: posix/LocalFileIterator.h:72
Definition: AbstractFileHandleBackend.h:14
Interface for iterating on directories.
Definition: AbstractFileIteratorBackend.h:22
std::shared_ptr< LocalFileSystem > m_fs
File system that created this iterator.
Definition: posix/LocalFileIterator.h:69
std::string m_path
Path to file or directory.
Definition: posix/LocalFileIterator.h:70
int m_index
Index of the current entry.
Definition: posix/LocalFileIterator.h:73
Interface for accessing file systems.
Definition: AbstractFileSystem.h:21