forked from tools/josh
1
0
Fork 0

Implement deleting root

This commit is contained in:
Florine W. Dekker 2018-11-29 00:21:35 +01:00
parent 9c53d17207
commit 739f74fe8c
Signed by: FWDekker
GPG Key ID: B1B567AF58D6EE0F
1 changed files with 11 additions and 1 deletions

View File

@ -266,6 +266,16 @@ class FileSystem {
rmdir(path, force) {
force = (force || false);
if (this._normalisePath(path) === "/") {
if (!force && Object.keys(this._root).length > 1) {
return `The directory is not empty.`;
} else {
this._root = {};
this._root["."] = this._root;
return ``;
}
}
const parentDirName = this._parentPath(path);
const childDirName = this._childPath(path);
@ -288,7 +298,7 @@ class FileSystem {
}
const fileToString = function(fileName, file) {
const fileToString = function (fileName, file) {
switch (file.type) {
case "link":
return `<a href="${file.link}">${fileName}</a>`;