mirror of
https://github.com/ondra-novak/gates_of_skeldal.git
synced 2025-07-22 15:14:49 -04:00
console portal jump
This commit is contained in:
parent
ce3e42f66b
commit
93caf370e4
4 changed files with 106 additions and 9 deletions
|
@ -111,17 +111,21 @@ int list_files(const char *directory, int type, LIST_FILES_CALLBACK cb, void *ct
|
|||
while (iter != std::filesystem::directory_iterator()) {
|
||||
int r = 0;
|
||||
const auto &entry = *iter;
|
||||
const char *name;
|
||||
if (type & file_type_just_name) name = entry.path().filename().c_str();
|
||||
else name = entry.path().filename().c_str();
|
||||
if (entry.is_regular_file(ec) && (type & file_type_normal)) {
|
||||
r = cb(entry.path().c_str(), file_type_normal, entry.file_size(ec), ctx);
|
||||
r = cb(name, file_type_normal, entry.file_size(ec), ctx);
|
||||
} else if (entry.is_directory(ec)) {
|
||||
int dot = entry.path().filename() == "." || entry.path().filename() == "..";
|
||||
if (!dot && (type & file_type_directory)) {
|
||||
r = cb(entry.path().c_str(), file_type_directory, 0, ctx);
|
||||
r = cb(name, file_type_directory, 0, ctx);
|
||||
} else if (dot & (type & file_type_dot)) {
|
||||
r = cb(entry.path().c_str(), file_type_dot, 0, ctx);
|
||||
r = cb(name, file_type_dot, 0, ctx);
|
||||
}
|
||||
}
|
||||
if (r) return r;
|
||||
++iter;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
@ -86,7 +86,8 @@ void sleep_ms(uint32_t);
|
|||
typedef enum {
|
||||
file_type_normal = 1,
|
||||
file_type_directory = 2,
|
||||
file_type_dot = 4
|
||||
file_type_dot = 4,
|
||||
file_type_just_name = 8
|
||||
} LIST_FILE_TYPE;
|
||||
|
||||
typedef int (*LIST_FILES_CALLBACK)(const char *, LIST_FILE_TYPE , size_t, void *);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue