-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileSystem.h
More file actions
58 lines (52 loc) · 2.19 KB
/
FileSystem.h
File metadata and controls
58 lines (52 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#pragma once
#include "AVLHTree.h"
#include "Rope.h"
#include <string>
#include <vector>
#include <memory>
using namespace std;
class FSNode;
class FileSystem {
shared_ptr<FSNode> root;
shared_ptr<FSNode> currentDir;
bool debugMode;
vector<string> splitPath(const string& path) const;
shared_ptr<FSNode> findNode(const string& path);
shared_ptr<FSNode> resolvePath(const string& path);
string getPathToNode(shared_ptr<FSNode> node);
bool checkReadPermission(shared_ptr<FSNode> node);
bool checkWritePermission(shared_ptr<FSNode> node);
bool checkExecutePermission(shared_ptr<FSNode> node);
void searchRecursive(shared_ptr<FSNode> node, const string& name,
const string& currentPath, vector<string>& results);
void visualizeTree(shared_ptr<FSNode> node, const string& prefix, bool isLast);
public:
FileSystem();
void toggleDebug();
bool isDebugMode() const;
string getCurrentPath() const;
bool changeDirectory(const string& path);
bool mkdir(const string& name);
bool touch(const string& name);
void cat(const string& name);
bool writeFile(const string& name, const string& content);
bool appendFile(const string& name, const string& content);
bool rm(const string& name, bool recursive = false);
void ls(bool showDetails = false);
void ls(const string& path, bool showDetails = false);
bool chmod(const string& mode, const string& name);
void findFiles(const string& name);
bool createDirectory(const string& path, bool silent = false);
bool createFile(const string& path, const string& content = "", bool silent = false);
bool writeToFile(const string& path, const string& content);
string readFile(const string& path);
int findInFile(const string& path, const string& substr);
bool deleteFromFile(const string& path, const string& substr);
bool insertInFile(const string& path, int pos, const string& text);
void listDirectory(const string& path);
vector<string> search(const string& name);
bool remove(const string& path);
bool setPermissions(const string& path, int owner, int group, int others);
void visualize();
void catFile(const string& path);
};