FSE/inc/FileSystem.hpp
2024-03-31 11:21:06 +03:00

43 lines
No EOL
1.2 KiB
C++

#pragma once
#include "Node.hpp"
#include "Path.hpp"
#include <sstream>
// use single vector for incoming links
// move link nodes from link to node class or vise versa
// clean-ups
// links have unique names
// copy operator exit if exists, do not rename
// in subtree links should be in-tree after copy operation
// update link if exists
class FileSystem {
public:
FileSystem();
~FileSystem();
bool makeDirectory(const Path& path);
bool makeFile(const Path& path);
bool changeCurrent(const Path& path);
bool removeDirectory(const Path& path, bool recursively);
bool removeFileOrLink(const Path& path);
bool copyNode(const Path& source, const Path& to);
bool moveNode(const Path& source, const Path& to);
bool makeLink(const Path& source, const Path& to, bool isDynamic);
std::ostream& dump(std::ostream& stream) const;
void log() const;
ui64 size() const;
static const std::string& getLastError();
private:
bool isPathContains(const std::shared_ptr<Node>& node, const std::shared_ptr<Node>& contains);
std::shared_ptr<Node> getNode(const Path& path, bool parent);
private:
std::shared_ptr<Node> root = nullptr;
std::shared_ptr<Node> currentDirectory = nullptr;
};