| 43 | rootNode = nullptr; |
| 44 | } |
| 45 | bool 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 | |
| 79 | void Fs::remoteNameToLocal(BString& path) { |
| 80 | path.replace(Fs::nativePathSeperator, "/"); |