Compare commits

...

2 Commits

Author SHA1 Message Date
3f48a19b22 desktop dir 2025-03-08 18:26:18 -05:00
74e3d5df60 optional timestamp 2025-03-08 18:26:07 -05:00
2 changed files with 13 additions and 26 deletions

View File

@ -5,28 +5,14 @@ import rfwfs from "../main"
const time_now = (Date.now()/1000)|0
// ------------ Home ------------
// /home/user/.config
const config = rfwfs.directory(".config", Permissions.rw, time_now)
// /home/user/.local
const local = rfwfs.directory(".local", Permissions.rw, time_now)
// /home/user/Downloads
const config = rfwfs.directory(".config", Permissions.rw, time_now)
const local = rfwfs.directory(".local", Permissions.rw, time_now)
const downloads = rfwfs.directory("Downloads", Permissions.rw, time_now)
const pictures = rfwfs.directory("Pictures", Permissions.rw, time_now)
const desktop = rfwfs.directory("Desktop", Permissions.rw, time_now)
const videos = rfwfs.directory("Videos", Permissions.rw, time_now)
const music = rfwfs.directory("Music", Permissions.rw, time_now)
// /home/user/Pictures
const pictures = rfwfs.directory("Pictures", Permissions.rw, time_now)
// /home/user/Videos
const videos = rfwfs.directory("Videos", Permissions.rw, time_now)
// /home/user/Music
const music = rfwfs.directory("Music", Permissions.rw, time_now)
// /home/user/Desktop
const desktop = rfwfs.directory("Desktop", Permissions.rw, time_now)
// /home/user
const user = rfwfs.directory("user", Permissions.r, time_now, [
config,
local,
@ -42,7 +28,7 @@ const home = rfwfs.directory("home", Permissions.r, time_now, [user])
// ------------
// ------------ root ------------
const bin = rfwfs.directory("bin", Permissions.r, time_now, [])
const bin = rfwfs.directory("bin", Permissions.r, time_now)
// ------------
export default rfwfs.directory("/", Permissions.r, time_now, [

View File

@ -24,6 +24,7 @@ interface EntryFile extends Entry {
interface EntryCollection<T extends Entry> extends Entry {
inner: EntryCollectionManipulate<T>,
}
interface EntryCollectionManipulate<T extends Entry> {
__body: T[],
clone: (file_name: string) => WrapResultEntry<T, ReadStatus>
@ -34,10 +35,10 @@ interface EntryCollectionManipulate<T extends Entry> {
}
interface Rfwfs {
directory: <T extends Entry>(default_name: string, permissions: Permissions, timestamp: number, inner_default?: T[]) => EntryCollection<T>,
directory: <T extends Entry>(default_name: string, permissions: Permissions, timestamp?: number, inner_default?: T[]) => EntryCollection<T>,
is_file: <T extends Entry>(entry: T) => boolean,
is_dir: <T extends Entry>(entry: T) => boolean,
file: (default_name: string, permissions: Permissions, timestamp: number, inner_default?: FileInner) => EntryFile,
file: (default_name: string, permissions: Permissions, timestamp?: number, inner_default?: FileInner) => EntryFile,
}
function read_write_access(permissions: Permissions): boolean {
@ -143,17 +144,17 @@ rfwfs.is_file = function(entry) {
rfwfs.file = function(default_name, permissions, timestamp, inner_default) {
const file = { type: EntryType.File } as EntryFile
file.permissions = permissions
file.timestamp = timestamp
file.timestamp = timestamp ? timestamp : (Date.now()/1000)|0
file.inner = file_inner(permissions, inner_default ? inner_default : "")
file.name = default_name
file.hash = "0"
return file
}
rfwfs.directory = function<T extends Entry>(default_name: string, permissions: Permissions, timestamp: number, inner_default?: T[]): EntryCollection<T> {
rfwfs.directory = function<T extends Entry>(default_name: string, permissions: Permissions, timestamp?: number, inner_default?: T[]): EntryCollection<T> {
const directory = { type: EntryType.Directory } as EntryCollection<T>
directory.permissions = permissions
directory.timestamp = timestamp
directory.timestamp = timestamp ? timestamp : (Date.now()/1000)|0
directory.inner = dir_inner(directory, inner_default ? inner_default : [])
directory.name = default_name
return directory