mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
fixed worlds list scanning
This commit is contained in:
parent
a4a5aef422
commit
1c99dfa180
5 changed files with 74 additions and 43 deletions
|
|
@ -2,7 +2,9 @@
|
|||
|
||||
#include <filesystem>
|
||||
#include <sstream>
|
||||
|
||||
#include "../typedefs.h"
|
||||
#include "WorldFiles.h"
|
||||
|
||||
#define SCREENSHOTS_FOLDER "screenshots"
|
||||
|
||||
|
|
@ -41,6 +43,27 @@ fs::path EnginePaths::getWorldsFolder() {
|
|||
return userfiles/fs::path("worlds");
|
||||
}
|
||||
|
||||
std::vector<fs::path> EnginePaths::scanForWorlds() {
|
||||
std::vector<fs::path> folders;
|
||||
|
||||
fs::path folder = getWorldsFolder();
|
||||
if (!fs::is_directory(folder))
|
||||
return folders;
|
||||
|
||||
for (auto entry : fs::directory_iterator(folder)) {
|
||||
if (!entry.is_directory()) {
|
||||
continue;
|
||||
}
|
||||
fs::path worldFolder = entry.path();
|
||||
fs::path worldFile = worldFolder/fs::path(WorldFiles::WORLD_FILE);
|
||||
if (!fs::is_regular_file(worldFile)) {
|
||||
continue;
|
||||
}
|
||||
folders.push_back(worldFolder);
|
||||
}
|
||||
return folders;
|
||||
}
|
||||
|
||||
bool EnginePaths::isWorldNameUsed(std::string name) {
|
||||
return fs::exists(EnginePaths::getWorldsFolder()/fs::u8path(name));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue