feat: added abstraction for wd::common::interfaces::storage

This commit is contained in:
CT5
2026-01-24 16:44:49 +11:00
parent 6e5e0900ce
commit 8e249bb7a6
2 changed files with 48 additions and 10 deletions

View File

@@ -1,22 +1,31 @@
//
// Created by DexrnZacAttack on 1/23/26 using zPc-i2.
//
#ifndef WINDURANGO_ABSTRACTSTORAGE_H
#define WINDURANGO_ABSTRACTSTORAGE_H
#pragma once
#include <filesystem>
#include "File.h"
namespace wd::common::interfaces::storage {
// TODO should we have separate project for interfaces?
/** Interface for storage management, to be impl'd for uwp and crossplat */
/*
* Interface for storage management, to be impl'd for uwp and crossplat
*
* We don't need any args for the constructor
* nor any vars bc this is an abstraction.
*/
class Directory {
public:
Directory(std::filesystem::path root); // todo impl
Directory() {}
virtual void CreateFile(std::filesystem::path path) = 0; // todo maybe return stream type, todo can we use this in uwp context??? I forgor
virtual void CreateDirectory(std::filesystem::path path) = 0;
virtual File CreateFile(std::filesystem::path path) = 0; // todo maybe return stream type, todo can we use this in uwp context??? I forgor
virtual Directory CreateDirectory(std::filesystem::path path) = 0;
std::filesystem::path _root;
virtual std::filesystem::path filepath() = 0;
virtual bool rename(std::string) = 0;
virtual bool remove() = 0;
virtual bool move(std::filesystem::path path) = 0;
virtual bool copy(std::filesystem::path path) = 0;
};
} // wd::common::interfaces::storage
#endif // WINDURANGO_ABSTRACTSTORAGE_H
} // wd::common::interfaces::storage

View File

@@ -0,0 +1,29 @@
/*
* wd::common::interfaces::storage::File
*/
#pragma once
#include <istream>
#include <filesystem>
namespace wd::common::interfaces::storage {
// TODO should we have separate project for interfaces?
/** Interface for storage management, to be impl'd for uwp and crossplat */
class File {
public:
File() {}
virtual bool open() = 0;
virtual bool create() = 0;
virtual std::istream& read() = 0;
virtual void operator<<(std::string data) = 0; // write
virtual bool close() = 0;
virtual std::filesystem::path filepath() = 0;
virtual bool rename(std::string) = 0;
virtual bool remove() = 0;
virtual bool move(std::filesystem::path path) = 0;
virtual bool copy(std::filesystem::path path) = 0;
};
}