summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cd-tool.lua32
1 files changed, 30 insertions, 2 deletions
diff --git a/cd-tool.lua b/cd-tool.lua
index 7b37d0f..30ebd34 100644
--- a/cd-tool.lua
+++ b/cd-tool.lua
@@ -2,6 +2,30 @@
-- misc functions --
------------------
+function extract_file(source, dest, mode)
+ if (mode == nil) then
+ source = cdfile(findpath(source))
+ else
+ source = cdfile(findpath(source), mode)
+ end
+ dest = Output(dest)
+ source.copyto(dest)
+end
+
+function insert_file(source, dest, mode)
+ if (type(source) == "string") then
+ source = Input(source)
+ end
+ if (type(dest) == "string") then
+ dest = findpath(dest)
+ end
+ if (mode == nil) then
+ writefile(source, -1, dest.Sector)
+ else
+ writefile(source, -1, dest.Sector, mode)
+ end
+end
+
function display(inp)
if (type(inp) == "string") then
inp = Input(inp)
@@ -16,7 +40,7 @@ end
function pchar(n)
if (not ((n >= 32) and (n <= 127))) then
- n = 46
+ n = 46 -- a dot, 0x2e.
end
return hex(n, "%c")
end
@@ -209,7 +233,11 @@ end
function findpath(path)
check_cdutil()
- return cdutil:findpath(path)
+ if (findpath == nil) then
+ return cdutil:findpath "/"
+ else
+ return cdutil:findpath(path)
+ end
end
function findparent(path)