refactor
This commit is contained in:
parent
4c97f6b098
commit
9a1483377c
@ -45,11 +45,14 @@ auto get_directory_files(std::string_view path, bool oldest_first,
|
|||||||
auto full_path = utils::path::combine(abs_path, {fd.cFileName});
|
auto full_path = utils::path::combine(abs_path, {fd.cFileName});
|
||||||
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ==
|
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) ==
|
||||||
FILE_ATTRIBUTE_DIRECTORY) {
|
FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
if (recursive) {
|
std::string name{fd.cFileName};
|
||||||
|
if (name == "." || name == ".." || not recursive) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto sub_files =
|
auto sub_files =
|
||||||
get_directory_files(full_path, oldest_first, recursive);
|
get_directory_files(full_path, oldest_first, recursive);
|
||||||
ret.insert(ret.end(), sub_files.begin(), sub_files.end());
|
ret.insert(ret.end(), sub_files.begin(), sub_files.end());
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
ULARGE_INTEGER li{};
|
ULARGE_INTEGER li{};
|
||||||
li.HighPart = fd.ftLastWriteTime.dwHighDateTime;
|
li.HighPart = fd.ftLastWriteTime.dwHighDateTime;
|
||||||
@ -75,14 +78,16 @@ auto get_directory_files(std::string_view path, bool oldest_first,
|
|||||||
struct dirent *de{};
|
struct dirent *de{};
|
||||||
while ((de = readdir(root)) != nullptr) {
|
while ((de = readdir(root)) != nullptr) {
|
||||||
if (de->d_type == DT_DIR) {
|
if (de->d_type == DT_DIR) {
|
||||||
if (recursive) {
|
std::string name{de->d_name};
|
||||||
auto sub_files = get_directory_files(
|
if (name == "." || name == ".." || not recursive) {
|
||||||
utils::path::combine(abs_path, {de->d_name}), oldest_first,
|
continue;
|
||||||
recursive);
|
|
||||||
ret.insert(ret.end(), sub_files.begin(), sub_files.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto sub_files = get_directory_files(
|
||||||
|
utils::path::combine(abs_path, {name}), oldest_first, recursive);
|
||||||
|
ret.insert(ret.end(), sub_files.begin(), sub_files.end());
|
||||||
} else {
|
} else {
|
||||||
ret.emplace_back(utils::path::combine(abs_path, {de->d_name}));
|
ret.emplace_back(utils::path::combine(abs_path, {name}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user