diff options
| author | hachem <im@hachem.wtf> | 2026-10-11 02:16:56 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-10-11 02:16:56 +0200 |
| commit | 59794d0b999e544a94230d9562bf2b99d2ed74c7 (patch) | |
| tree | a001db5b5ebb9453d6a0e96f56b36e6ec3ccdd51 /gils | |
| parent | 88750ed7132c08bcfb24e878c893ef7185c3c0b0 (diff) | |
feat: actual real vfs, not a faked one lmao
Diffstat (limited to 'gils')
| -rw-r--r-- | gils/cat.rv | 3 | ||||
| -rw-r--r-- | gils/cp.rv | 6 | ||||
| -rw-r--r-- | gils/ed.rv | 8 | ||||
| -rw-r--r-- | gils/head.rv | 4 | ||||
| -rw-r--r-- | gils/ls.rv | 11 | ||||
| -rw-r--r-- | gils/mkdir.rv | 2 | ||||
| -rw-r--r-- | gils/mv.rv | 8 | ||||
| -rw-r--r-- | gils/rm.rv | 2 | ||||
| -rw-r--r-- | gils/tail.rv | 4 | ||||
| -rw-r--r-- | gils/touch.rv | 6 | ||||
| -rw-r--r-- | gils/tree.rv | 12 | ||||
| -rw-r--r-- | gils/wc.rv | 4 |
12 files changed, 26 insertions, 44 deletions
diff --git a/gils/cat.rv b/gils/cat.rv index 0666304..cb0df34 100644 --- a/gils/cat.rv +++ b/gils/cat.rv @@ -5,6 +5,5 @@ const parsed = arg_name(context.rest, 0) if parsed.name:len() == 0 do fail("usage: cat <path>\n") end else do const path = expand_path(parsed.name) - if vfs_owns(path) do vfs_cat(path) end - else do fs:cat(path) end + vfs:cat(path) end @@ -8,13 +8,13 @@ if context.argv:len() < 3 do end else do const source = expand_path(context.argv[1]) const destination = expand_path(context.argv[2]) - const size = fs:size(source) + const size = vfs:size(source) if size < 0 do fail("cp: #{source}: no such file\n") end else do - const contents = if (size > 0) fs:read_bytes(source, 0, size) else "" - if (fs:store(destination, contents) == 1) + const contents = if (size > 0) vfs:read_bytes(source, 0, size) else "" + if (vfs:store(destination, contents) == 1) puts("#{source} -> #{destination}\n") end end @@ -211,7 +211,7 @@ fn ed_write(state, command) do const contents = ed_join(state.lines) - fs:store(path, contents) + vfs:store(path, contents) state.path = path state.dirty = :false puts("#{contents:len()}\n") @@ -267,7 +267,7 @@ fn ed_run_file(state, line, parsed) do const path = expand_path(rest:split(" ")[0]) - if fs:size(path) < 0 do + if vfs:size(path) < 0 do puts("?\n") return :nil end @@ -337,10 +337,10 @@ fn gils_ed(context) -> :hold do else "" if ed_state.path:len() > 0 do - const size = fs:size(ed_state.path) + const size = vfs:size(ed_state.path) if size > 0 do - const contents = fs:read_bytes(ed_state.path, 0, size) + const contents = vfs:read_bytes(ed_state.path, 0, size) const raw_lines = contents:split("\n") for index in 0..raw_lines:len() do diff --git a/gils/head.rv b/gils/head.rv index eb50087..c124ed3 100644 --- a/gils/head.rv +++ b/gils/head.rv @@ -1,11 +1,11 @@ # gimme some head lung fn file_lines(path) -> table | :nil do - const size = fs:size(path) + const size = vfs:size(path) if (size < 0) return :nil - const contents = if (size > 0) fs:read_bytes(path, 0, size) else "" + const contents = if (size > 0) vfs:read_bytes(path, 0, size) else "" const raw_lines = contents:split("\n") let result = {} for index in 0..raw_lines:len() do @@ -3,13 +3,4 @@ const context = env.ctx const target = if (context.argv:len() > 1) expand_path(context.argv[1]) else wd.path -if vfs_owns(target) do - vfs_ls(target) -end else do - const count = fs:ls(target) - if target == "/" do - puts(" proc/\n") - end else if count == 0 do - puts(" (empty)\n") - end -end +vfs:ls(target) diff --git a/gils/mkdir.rv b/gils/mkdir.rv index 9da7689..f701ac9 100644 --- a/gils/mkdir.rv +++ b/gils/mkdir.rv @@ -5,5 +5,5 @@ const context = env.ctx if context.argv:len() < 2 do fail("usage: mkdir <path>\n") end else do - fs:mkdir(expand_path(context.argv[1])) + vfs:mkdir(expand_path(context.argv[1])) end @@ -6,14 +6,14 @@ if context.argv:len() < 3 do end else do const source = expand_path(context.argv[1]) const destination = expand_path(context.argv[2]) - const size = fs:size(source) + const size = vfs:size(source) if size < 0 do fail("mv: #{source}: no such file\n") end else do - const contents = if (size > 0) fs:read_bytes(source, 0, size) else "" - if fs:store(destination, contents) == 1 do - fs:unlink(source) + const contents = if (size > 0) vfs:read_bytes(source, 0, size) else "" + if vfs:store(destination, contents) == 1 do + vfs:unlink(source) puts("#{source} -> #{destination}\n") end end @@ -6,5 +6,5 @@ const parsed = arg_name(context.rest, 0) if parsed.name:len() == 0 do fail("usage: rm <path>\n") end else do - fs:rm(expand_path(parsed.name)) + vfs:rm(expand_path(parsed.name)) end diff --git a/gils/tail.rv b/gils/tail.rv index c0ce1df..b5513a6 100644 --- a/gils/tail.rv +++ b/gils/tail.rv @@ -2,11 +2,11 @@ # and its between my legs fn file_lines(path) -> table | :nil do - const size = fs:size(path) + const size = vfs:size(path) if (size < 0) return :nil - const contents = if (size > 0) fs:read_bytes(path, 0, size) else "" + const contents = if (size > 0) vfs:read_bytes(path, 0, size) else "" const raw_lines = contents:split("\n") let result = {} diff --git a/gils/touch.rv b/gils/touch.rv index 3032e96..5e27309 100644 --- a/gils/touch.rv +++ b/gils/touch.rv @@ -5,9 +5,9 @@ if context.argv:len() < 2 do fail("usage: touch <path>\n") end else do const path = expand_path(context.argv[1]) - if fs:is_dir(path) do + if vfs:is_dir(path) do fail("touch: #{path}: is a directory\n") - end else if fs:size(path) < 0 do - fs:store(path, "") + end else if vfs:size(path) < 0 do + vfs:store(path, "") end end diff --git a/gils/tree.rv b/gils/tree.rv index d146403..4aad0df 100644 --- a/gils/tree.rv +++ b/gils/tree.rv @@ -1,7 +1,7 @@ # recursive directory listing fn tree_walk(path, prefix) do - const items = fs:entries(path) + const items = vfs:entries(path) if (items == :nil) return :nil @@ -29,17 +29,9 @@ end const context = env.ctx const target = if (context.argv:len() > 1) expand_path(context.argv[1]) else wd.path -if vfs_owns(target) and target != "/" do - fail("tree: #{target}: virtual dir\n") -end else if target != "/" and fs:is_dir(target) == :false do +if vfs:is_dir(target) == :false do fail("tree: #{target}: not a directory\n") end else do puts("#{target}\n") tree_walk(target, "") - # /proc is the one thing not on disk so tack it on at root - if target == "/" do - puts("`-- proc/\n") - puts(" |-- uptime\n") - puts(" `-- meminfo\n") - end end @@ -5,12 +5,12 @@ if context.argv:len() < 2 do fail("usage: wc <path>\n") end else do const path = expand_path(context.argv[1]) - const size = fs:size(path) + const size = vfs:size(path) if size < 0 do fail("wc: #{path}: no such file\n") end else do - const contents = if (size > 0) fs:read_bytes(path, 0, size) else "" + const contents = if (size > 0) vfs:read_bytes(path, 0, size) else "" let line_count = 0 let word_count = 0 let in_word = :false |
