MCPcopy Create free account
hub / github.com/BernardoGiordano/Checkpoint / ckpt_read_directory

Function ckpt_read_directory

common/script/checkpoint_api.cpp:214–236  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212/* ---- sd card --------------------------------------------------------- */
213
214void ckpt_read_directory(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs)
215{
216 std::string dir = ScriptArgs(Parser, Param, NumArgs, "read_directory").str(0);
217 // Drop trailing slashes before joining so entries never contain "//": a dir
218 // from title_backup_path ends in '/', and "dir//name" opens here (this call)
219 // but the FS rejects the empty component when a later opendir/stat (e.g.
220 // zip_dir's collect) walks the returned path — the symptom was an empty zip.
221 while (dir.size() > 1 && dir.back() == '/') {
222 dir.pop_back();
223 }
224 std::vector<std::string> names;
225 if (DIR* d = opendir(dir.c_str())) {
226 while (struct dirent* ent = readdir(d)) {
227 const std::string name = ent->d_name;
228 if (name != "." && name != "..") {
229 names.push_back(dir + "/" + name);
230 }
231 }
232 closedir(d);
233 }
234
235 ReturnValue->Val->Pointer = makeDirData(names);
236}
237
238void ckpt_delete_directory(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs)
239{

Callers

nothing calls this directly

Calls 7

ScriptArgsClass · 0.85
makeDirDataFunction · 0.85
strMethod · 0.80
backMethod · 0.80
pop_backMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected