MCPcopy Create free account
hub / github.com/danoon2/Boxedwine / initFileSystem

Method initFileSystem

source/io/fs.cpp:45–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43 rootNode = nullptr;
44}
45bool Fs::initFileSystem(const BString& rootPath) {
46 Fs::nextNodeId = 1;
47 BString path;
48 Fs::nativePathSeperator = (char)std::filesystem::path::preferred_separator;
49 if (rootPath.endsWith("/")) {
50 path = rootPath.substr(0, rootPath.length()-1);
51 } else if (rootPath.endsWith("\\")) {
52 path = rootPath.substr(0, rootPath.length()-1);
53 } else {
54 path = rootPath;
55 }
56
57 if (MKDIR(rootPath.c_str())==0) {
58 klog_fmt("Created root directory: %s", rootPath.c_str());
59 }
60
61 std::shared_ptr<FsNode> parent(nullptr);
62 rootNode = std::make_shared<FsFileNode>(Fs::nextNodeId++, 0, B("/"), B(""), path, true, true, parent);
63
64 std::shared_ptr<FsNode> dir = Fs::getNodeFromLocalPath(B(""), B("/tmp/del"), false, nullptr);
65 if (dir) {
66 std::vector<std::shared_ptr<FsNode> > children;
67 dir->getAllChildren(children);
68 for (U32 i=0;i<children.size();i++) {
69 children[i]->remove();
70 }
71 }
72 std::shared_ptr<FsNode> lock = Fs::getNodeFromLocalPath(B(""), B("/tmp/.X0-lock"), false, nullptr);
73 if (lock) {
74 lock->remove();
75 }
76 return true;
77}
78
79void Fs::remoteNameToLocal(BString& path) {
80 path.replace(Fs::nativePathSeperator, "/");

Callers

nothing calls this directly

Calls 9

klog_fmtFunction · 0.85
BFunction · 0.85
endsWithMethod · 0.80
substrMethod · 0.80
getAllChildrenMethod · 0.80
lengthMethod · 0.45
c_strMethod · 0.45
sizeMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected