Directory.h
Go to the documentation of this file.
1 
22 #pragma once
23 
24 #include "FsBase.h"
25 
26 namespace IFS
27 {
31 class Directory : public FsBase
32 {
33 public:
34  using FsBase::FsBase;
35 
37  {
38  close();
39  }
40 
47  bool open(const String& dirName = nullptr);
48 
52  void close();
53 
59  bool rewind();
60 
65  const String& getDirName() const
66  {
67  return name;
68  }
69 
74  bool dirExist() const
75  {
76  return dir != nullptr;
77  }
78 
82  String getPath() const;
83 
88  String getParent() const;
89 
90  int index() const
91  {
92  return currentIndex;
93  }
94 
95  size_t count() const
96  {
97  return size_t(maxIndex + 1);
98  }
99 
100  bool isValid() const
101  {
102  return currentIndex >= 0;
103  }
104 
105  size_t size() const
106  {
107  return totalSize;
108  }
109 
110  const Stat& stat() const
111  {
112  return dirStat;
113  }
114 
115  bool next();
116 
117 private:
118  String name;
119  DirHandle dir{};
120  NameStat dirStat;
121  int currentIndex{-1};
122  int maxIndex{-1};
123  size_t totalSize{0};
124 };
125 
126 } // namespace IFS
version of Stat with integrated name buffer
Definition: Stat.h:97
FsBase(IFileSystem *filesys)
Definition: FsBase.h:36
const Stat & stat() const
Definition: Directory.h:110
size_t size() const
Definition: Directory.h:105
String getParent() const
Get parent directory.
struct ImplFileDir * DirHandle
Definition: IFileSystem.h:68
~Directory()
Definition: Directory.h:36
bool dirExist() const
Determine if directory exists.
Definition: Directory.h:74
The String class.
Definition: WString.h:136
bool open(const String &dirName=nullptr)
Open a directory and attach this stream object to it.
bool rewind()
Rewind directory stream to start so it can be re-enumerated.
Wrapper class for enumerating a directory.
Definition: Directory.h:31
Definition: DirectoryTemplate.h:36
void close()
Close directory.
bool isValid() const
Definition: Directory.h:100
File Status structure.
Definition: Stat.h:51
size_t count() const
Definition: Directory.h:95
const String & getDirName() const
Name of directory stream is attached to.
Definition: Directory.h:65
int index() const
Definition: Directory.h:90
Definition: FsBase.h:33
String getPath() const
Get path with leading separator /path/to/dir.