kibibyte init
This commit is contained in:
8
.zed/settings.json
Normal file
8
.zed/settings.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Folder-specific settings
|
||||||
|
//
|
||||||
|
// For a full list of overridable settings, and general information on folder-specific settings,
|
||||||
|
// see the documentation: https://zed.dev/docs/configuring-zed#settings-files
|
||||||
|
{
|
||||||
|
"hard_tabs": true,
|
||||||
|
"tab_size": 4
|
||||||
|
}
|
@ -1,23 +1,59 @@
|
|||||||
import { ReadStatus } from "../enum"
|
import { ReadStatus } from "../enum"
|
||||||
import rfwfs, { type EntryCollection, type Entry } from "../main"
|
import rfwfs, { type EntryCollection, type Entry, RfwfsDirectory } from "../main"
|
||||||
|
|
||||||
|
import wrap, { wrap_none, WrapResult, WrapResultEntry, WrapResultNone } from "../wrap"
|
||||||
import fs from "./root"
|
import fs from "./root"
|
||||||
|
|
||||||
|
const enum TraverseStatus {
|
||||||
|
Ok,
|
||||||
|
Denied,
|
||||||
|
TargetMissing,
|
||||||
|
NotFound,
|
||||||
|
}
|
||||||
|
|
||||||
let username: string = "user"
|
let username: string = "user"
|
||||||
|
|
||||||
const libhome = {} as LibHome
|
const libhome = {} as LibHome
|
||||||
|
|
||||||
interface WorkingDir<T extends Entry> {
|
interface WorkingDir<T extends Entry> {
|
||||||
entry?: EntryCollection<T>,
|
entry?: EntryCollection<T>,
|
||||||
path: string[]
|
|
||||||
}
|
}
|
||||||
interface LibHome {
|
interface LibHome {
|
||||||
path: () => string[],
|
path: () => string[],
|
||||||
get: <T extends Entry>() => EntryCollection<T>,
|
get: <T extends Entry>() => EntryCollection<T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
function traverse_to_goal(path: string[]) {
|
function working_path_result(find: WrapResultEntry<EntryCollection<Entry>, ReadStatus>): WrapResult<TraverseStatus> {
|
||||||
if (working_dir.entry) {
|
// switch(find.some) {
|
||||||
|
// case ReadStatus.Ok: {
|
||||||
|
// return wrap(TraverseStatus.Ok, find.result)
|
||||||
|
// }
|
||||||
|
// case ReadStatus.NotFound: {
|
||||||
|
// }
|
||||||
|
// case ReadStatus.Denied: {
|
||||||
|
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
if (find.some === ReadStatus.Ok) {
|
||||||
|
if (find.result) {
|
||||||
|
return wrap(TraverseStatus.Ok)
|
||||||
|
} else {
|
||||||
|
}
|
||||||
|
} else if (find.some === ReadStatus.Denied) {
|
||||||
|
|
||||||
|
} else if (find.some === ReadStatus.NotFound) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return wrap_none(TraverseStatus.NotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
function traverse_to_goal(working_path: string[]) {
|
||||||
|
let working_dir = fs.inner
|
||||||
|
|
||||||
|
for (const dir_name of working_path) {
|
||||||
|
const find = working_dir.find(dir_name)
|
||||||
|
const h = working_path_result(find)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,13 +5,14 @@ import rfwfs from "../main"
|
|||||||
const time_now = (Date.now()/1000)|0
|
const time_now = (Date.now()/1000)|0
|
||||||
|
|
||||||
// ------------ Home ------------
|
// ------------ Home ------------
|
||||||
const config = rfwfs.directory(".config", Permissions.rw, time_now)
|
const
|
||||||
const local = rfwfs.directory(".local", Permissions.rw, time_now)
|
config = rfwfs.directory(".config", Permissions.rw, time_now),
|
||||||
const downloads = rfwfs.directory("Downloads", Permissions.rw, time_now)
|
local = rfwfs.directory(".local", Permissions.rw, time_now),
|
||||||
const pictures = rfwfs.directory("Pictures", Permissions.rw, time_now)
|
downloads = rfwfs.directory("Downloads", Permissions.rw, time_now),
|
||||||
const desktop = rfwfs.directory("Desktop", Permissions.rw, time_now)
|
pictures = rfwfs.directory("Pictures", Permissions.rw, time_now),
|
||||||
const videos = rfwfs.directory("Videos", Permissions.rw, time_now)
|
desktop = rfwfs.directory("Desktop", Permissions.rw, time_now),
|
||||||
const music = rfwfs.directory("Music", Permissions.rw, time_now)
|
videos = rfwfs.directory("Videos", Permissions.rw, time_now),
|
||||||
|
music = rfwfs.directory("Music", Permissions.rw, time_now);
|
||||||
|
|
||||||
const user = rfwfs.directory("user", Permissions.r, time_now, [
|
const user = rfwfs.directory("user", Permissions.r, time_now, [
|
||||||
config,
|
config,
|
||||||
|
24
src/rt/rfwfs/result.ts
Normal file
24
src/rt/rfwfs/result.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
const enum Status {
|
||||||
|
Ok,
|
||||||
|
Err
|
||||||
|
}
|
||||||
|
|
||||||
|
type OkResult<T> = [Status.Ok, T];
|
||||||
|
type ErrResult<T extends Error> = [Status.Err, T]
|
||||||
|
|
||||||
|
type Result<T, U extends Error> = OkResult<T> | ErrResult<U>;
|
||||||
|
|
||||||
|
const Ok = <T>(value: T) => [Status.Ok, value] satisfies OkResult<T>;
|
||||||
|
const Err = <T extends Error>(value: T) => [Status.Err, value] satisfies ErrResult<T>;
|
||||||
|
|
||||||
|
const execute = <T>(value: T): Result<T, Error> => {
|
||||||
|
return Math.random() > 0.5 ? Ok(value) : Err(new Error("boom"));
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = execute("whatever");
|
||||||
|
|
||||||
|
if (result[0] === Status.Ok) {
|
||||||
|
const value = result[1]; // it have to be string
|
||||||
|
} else {
|
||||||
|
const value = result[1]; // it have to be error
|
||||||
|
}
|
Reference in New Issue
Block a user