Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <string>
- #include <filesystem>
- namespace fs = std::filesystem;
- namespace os {
- const char* path_separator() { return "\\"; }
- }
- const char java_home[] = "B:\\java\\mc\\builds\\windows-x86_64-mc-release-skylake-x";
- int main() {
- auto fprintln = [](const std::string& str) {
- printf("%s\n", str.c_str());
- };
- fs::path overrideRoot = java_home;
- fprintln(overrideRoot.string());
- overrideRoot /= "override";
- fprintln(overrideRoot.string());
- fs::directory_entry overrideDir{ overrideRoot };
- if (overrideDir.is_directory()) {
- using iterator = fs::recursive_directory_iterator;
- for (iterator iter{ overrideDir }; iter != iterator(); ++iter) {
- // works fine
- const auto & override = *iter;
- fprintln(override.path().string());
- if (override.exists() && !override.is_directory()) {
- std::string overridePath = override.path().string();
- fprintln(overridePath);
- }
- }
- for (const auto & override : iterator{ overrideDir }) {
- // works fine
- fprintln(override.path().string());
- if (override.exists() && !override.is_directory()) {
- std::string overridePath = override.path().string();
- fprintln(overridePath);
- }
- }
- for (const auto & override : iterator( overrideDir )) {
- // doesn't enter
- if (override.exists() && !override.is_directory()) {
- std::string overridePath = override.path().string();
- puts(overridePath.c_str());
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement