update io::SubDevice constructor
This commit is contained in:
@@ -0,0 +1,16 @@
|
|||||||
|
#include "Device.hpp"
|
||||||
|
|
||||||
|
#include "../io.hpp"
|
||||||
|
|
||||||
|
using namespace io;
|
||||||
|
|
||||||
|
SubDevice::SubDevice(
|
||||||
|
std::shared_ptr<Device> parent,
|
||||||
|
const std::string& path,
|
||||||
|
bool createDirectory
|
||||||
|
)
|
||||||
|
: parent(std::move(parent)), root(path) {
|
||||||
|
if (createDirectory && !this->parent->exists(path)) {
|
||||||
|
this->parent->mkdirs(path);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -28,8 +28,11 @@ namespace io {
|
|||||||
|
|
||||||
class SubDevice : public Device {
|
class SubDevice : public Device {
|
||||||
public:
|
public:
|
||||||
SubDevice(std::shared_ptr<Device> parent, const std::string& path)
|
SubDevice(
|
||||||
: parent(std::move(parent)), root(path) {}
|
std::shared_ptr<Device> parent,
|
||||||
|
const std::string& path,
|
||||||
|
bool createDirectory = true
|
||||||
|
);
|
||||||
|
|
||||||
std::filesystem::path resolve(std::string_view path) override {
|
std::filesystem::path resolve(std::string_view path) override {
|
||||||
return parent->resolve((root / path).pathPart());
|
return parent->resolve((root / path).pathPart());
|
||||||
|
|||||||
Reference in New Issue
Block a user