mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
add file.create_memory_device, app.create_memory_device
This commit is contained in:
parent
654267f2d4
commit
0c517709a1
4 changed files with 40 additions and 4 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "debug/Logger.hpp"
|
||||
#include "io/devices/StdfsDevice.hpp"
|
||||
#include "io/devices/MemoryDevice.hpp"
|
||||
#include "io/devices/ZipFileDevice.hpp"
|
||||
#include "maths/util.hpp"
|
||||
#include "typedefs.hpp"
|
||||
|
|
@ -168,6 +169,18 @@ void EnginePaths::unmount(const std::string& name) {
|
|||
mounted.erase(found);
|
||||
}
|
||||
|
||||
std::string EnginePaths::createMemoryDevice() {
|
||||
auto device = std::make_unique<io::MemoryDevice>();
|
||||
std::string name;
|
||||
do {
|
||||
name = std::string("M.") + generate_random_base64<6>();
|
||||
} while (std::find(mounted.begin(), mounted.end(), name) != mounted.end());
|
||||
|
||||
io::set_device(name, std::move(device));
|
||||
mounted.push_back(name);
|
||||
return name;
|
||||
}
|
||||
|
||||
std::string EnginePaths::createWriteableDevice(const std::string& name) {
|
||||
const auto& found = writeables.find(name);
|
||||
if (found != writeables.end()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue