MCPcopy Create free account
hub / github.com/EasyRPG/Player / GetDirectoryContent

Method GetDirectoryContent

src/filesystem_native.cpp:119–149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

117}
118
119bool NativeFilesystem::GetDirectoryContent(std::string_view path, std::vector<DirectoryTree::Entry>& entries) const {
120 std::string p = ToString(path);
121
122 Platform::Directory dir(p);
123 if (!dir) {
124 Output::Debug("Error opening dir {}: {}", p, ::strerror(errno));
125 return false;
126 }
127
128 while (dir.Read()) {
129 const auto& name = dir.GetEntryName();
130 Platform::FileType type = dir.GetEntryType();
131
132 if (name == "." || name == "..") {
133 continue;
134 }
135
136 bool is_directory = false;
137 if (type == Platform::FileType::Directory) {
138 is_directory = true;
139 } else if (type == Platform::FileType::Unknown) {
140 is_directory = IsDirectory(name, true);
141 }
142
143 entries.emplace_back(
144 name,
145 is_directory ? DirectoryTree::FileType::Directory : DirectoryTree::FileType::Regular);
146 }
147
148 return true;
149}
150
151bool NativeFilesystem::MakeDirectory(std::string_view path, bool follow_symlinks) const {
152 return Platform::File(ToString(path)).MakeDirectory(follow_symlinks);

Callers

nothing calls this directly

Calls 3

GetEntryNameMethod · 0.80
GetEntryTypeMethod · 0.80
ReadMethod · 0.45

Tested by

no test coverage detected