This repository has been archived by the owner on Jul 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
200 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
body{ | ||
width: calc(100vw - 20px); | ||
padding: 10px; | ||
height: calc(100vh - 20px); | ||
margin: 0px; | ||
background-color: none; | ||
} | ||
navRail{ | ||
width: calc(100vw - 20px); | ||
background: rgba(14, 14, 14, 0.3); | ||
box-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25), inset 0px 4px 4px rgba(0, 0, 0, 0.25); | ||
border-radius: 5px; | ||
min-height: 30px; | ||
max-height: 50px; | ||
height: 1em; | ||
display: block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
<link rel="stylesheet" href="../appStyle.css"> | ||
<navRail> | ||
<back/> | ||
<forward/> | ||
<up/> | ||
<breadcrumbs></breadcrumbs> | ||
<search></search> | ||
</navRail> | ||
<partition size="1/4"></partition> | ||
<partition size="3/4"></partition> | ||
<body> | ||
<link rel="stylesheet" href="../appStyle.css"> | ||
<navRail> | ||
<back /> | ||
<forward /> | ||
<up /> | ||
<breadcrumbs></breadcrumbs> | ||
<search></search> | ||
</navRail> | ||
<partition size="1/4"> | ||
<ul id="fmBkms"></ul> | ||
</partition> | ||
<partition size="3/4"> | ||
<ul id="fileListing"></ul> | ||
</partition> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,171 @@ | ||
const opfsRoot = await navigator.storage.getDirectory(); | ||
window.foxyfs = { | ||
getFileHandle: async function (path1) { | ||
var path = path1.split("/") | ||
var nameofFile = path[path.length - 1] | ||
path[path.length - 1] = ''; | ||
path = path.filter(function (el) { | ||
return el != ''; | ||
}); | ||
var content = {}; | ||
if (path.length == 0) { | ||
var dirHandle = await opfsRoot.getDirectoryHandle(nameofFile); | ||
content[nameofFile] = dirHandle | ||
} | ||
else if (path.length > 1) { | ||
var dirHandle = await opfsRoot.getDirectoryHandle(path[0]); | ||
|
||
for (var item of path) { | ||
if (item == path[0]) { | ||
|
||
} else { | ||
dirHandle = await dirHandle.getDirectoryHandle(item) | ||
} | ||
} | ||
var content = {}; | ||
for await (let [name, handle] of dirHandle.entries()) { | ||
content[name] = handle | ||
} | ||
} else if (path.length == 1) { | ||
var dirHandle = await opfsRoot.getDirectoryHandle(path[0]); | ||
|
||
var content = {}; | ||
for await (let [name, handle] of dirHandle.entries()) { | ||
content[name] = handle | ||
} | ||
} | ||
return content[nameofFile] | ||
}, | ||
init: async function () { | ||
var directoryHandle = await opfsRoot.getDirectoryHandle('sys', { create: true }); | ||
directoryHandle = await opfsRoot.getDirectoryHandle('user', { create: true }); | ||
}, | ||
ls: async function (dir) { | ||
return await opfsRoot.getDirectoryHandle(dir); | ||
var path = dir.split("/") | ||
path = path.filter(function (el) { | ||
return el != ''; | ||
}); | ||
if (path.length == 0) { | ||
var content = {}; | ||
for await (let [name, handle] of opfsRoot.entries()) { | ||
content[name] = handle.kind | ||
} | ||
return content; | ||
} | ||
var dirHandle = await opfsRoot.getDirectoryHandle(path[0]); | ||
if (path.length > 1) { | ||
for (var item of path) { | ||
if (item == path[0]) { | ||
|
||
} else { | ||
dirHandle = await dirHandle.getDirectoryHandle(item) | ||
} | ||
} | ||
var content = {}; | ||
for await (let [name, handle] of dirHandle.entries()) { | ||
content[name] = handle.kind | ||
} | ||
return content; | ||
} else if (path.length == 1) { | ||
var content = {}; | ||
for await (let [name, handle] of dirHandle.entries()) { | ||
content[name] = handle.kind | ||
} | ||
return content; | ||
} | ||
}, | ||
mkdir: async function (location, name) { | ||
if (location == '' || location == "/") { | ||
return await opfsRoot.getDirectoryHandle(name, { create: true }); | ||
} else { | ||
var path = location.split("/") | ||
path = path.filter(function (el) { | ||
return el != ''; | ||
}); | ||
var dirHandle = await opfsRoot.getDirectoryHandle(path[0]) | ||
for (var item of path) { | ||
if (item == path[0]) { | ||
|
||
} else { | ||
dirHandle = await dirHandle.getDirectoryHandle(item) | ||
} | ||
} | ||
return await dirHandle.getDirectoryHandle(name, { create: true }) | ||
} | ||
}, | ||
touch: async function (location, name) { | ||
if (location == '' || location == "/") { | ||
return await opfsRoot.getFileHandle(name, { create: true }); | ||
} else { | ||
var path = location.split("/") | ||
path = path.filter(function (el) { | ||
return el != ''; | ||
}); | ||
var dirHandle = await opfsRoot.getDirectoryHandle(path[0]) | ||
for (var item of path) { | ||
if (item == path[0]) { | ||
|
||
} else { | ||
dirHandle = await dirHandle.getDirectoryHandle(item) | ||
} | ||
} | ||
return await dirHandle.getFileHandle(name, { create: true }) | ||
} | ||
}, | ||
typeof: async function (path1) { | ||
var path = path1.split("/") | ||
var nameofFile = path[path.length - 1] | ||
path[path.length - 1] = ''; | ||
path = path.filter(function (el) { | ||
return el != ''; | ||
}); | ||
var content = {}; | ||
if (path.length == 0) { | ||
var dirHandle = await opfsRoot.getDirectoryHandle(nameofFile); | ||
content[nameofFile] = dirHandle.kind | ||
} | ||
else if (path.length > 1) { | ||
var dirHandle = await opfsRoot.getDirectoryHandle(path[0]); | ||
|
||
for (var item of path) { | ||
if (item == path[0]) { | ||
|
||
} else { | ||
dirHandle = await dirHandle.getDirectoryHandle(item) | ||
} | ||
} | ||
var content = {}; | ||
for await (let [name, handle] of dirHandle.entries()) { | ||
content[name] = handle.kind | ||
} | ||
} else if (path.length == 1) { | ||
var dirHandle = await opfsRoot.getDirectoryHandle(path[0]); | ||
|
||
var content = {}; | ||
for await (let [name, handle] of dirHandle.entries()) { | ||
content[name] = handle.kind | ||
} | ||
} | ||
return content[nameofFile] | ||
}, | ||
read: async function (path) { | ||
var h = await foxyfs.getFileHandle(path) | ||
var file = await h.getFile() | ||
return await file.text() | ||
}, | ||
write: async function (path, content) { | ||
var h = await foxyfs.getFileHandle(path) | ||
var stream = await h.createWritable() | ||
stream.write(content) | ||
stream.close() | ||
return h; | ||
}, | ||
rmfile: async function (path){ | ||
h = await foxyfs.getFileHandle(path) | ||
h.remove() | ||
}, | ||
rmdir: async function (path, recursive=false){ | ||
|
||
} | ||
} | ||
foxyfs.init() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters