From 59794d0b999e544a94230d9562bf2b99d2ed74c7 Mon Sep 17 00:00:00 2001 From: hachem Date: Sun, 11 Oct 2026 02:16:56 +0200 Subject: feat: actual real vfs, not a faked one lmao --- gils/cat.rv | 3 +-- gils/cp.rv | 6 +++--- gils/ed.rv | 8 ++++---- gils/head.rv | 4 ++-- gils/ls.rv | 11 +---------- gils/mkdir.rv | 2 +- gils/mv.rv | 8 ++++---- gils/rm.rv | 2 +- gils/tail.rv | 4 ++-- gils/touch.rv | 6 +++--- gils/tree.rv | 12 ++---------- gils/wc.rv | 4 ++-- 12 files changed, 26 insertions(+), 44 deletions(-) (limited to 'gils') 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 \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 diff --git a/gils/cp.rv b/gils/cp.rv index 6fd06a8..e92ce21 100644 --- a/gils/cp.rv +++ b/gils/cp.rv @@ -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 diff --git a/gils/ed.rv b/gils/ed.rv index 023ce15..b3d4bfc 100644 --- a/gils/ed.rv +++ b/gils/ed.rv @@ -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 diff --git a/gils/ls.rv b/gils/ls.rv index 37f4b05..4afbb91 100644 --- a/gils/ls.rv +++ b/gils/ls.rv @@ -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 \n") end else do - fs:mkdir(expand_path(context.argv[1])) + vfs:mkdir(expand_path(context.argv[1])) end diff --git a/gils/mv.rv b/gils/mv.rv index d44b898..d87cb28 100644 --- a/gils/mv.rv +++ b/gils/mv.rv @@ -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 diff --git a/gils/rm.rv b/gils/rm.rv index 8c954f3..916ee3f 100644 --- a/gils/rm.rv +++ b/gils/rm.rv @@ -6,5 +6,5 @@ const parsed = arg_name(context.rest, 0) if parsed.name:len() == 0 do fail("usage: rm \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 \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 diff --git a/gils/wc.rv b/gils/wc.rv index 75a3ed2..33dd1e6 100644 --- a/gils/wc.rv +++ b/gils/wc.rv @@ -5,12 +5,12 @@ if context.argv:len() < 2 do fail("usage: wc \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 -- cgit v1.3