| 212 | /* ---- sd card --------------------------------------------------------- */ |
| 213 | |
| 214 | void 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 | |
| 238 | void ckpt_delete_directory(struct ParseState* Parser, struct Value* ReturnValue, struct Value** Param, int NumArgs) |
| 239 | { |
nothing calls this directly
no test coverage detected