summaryrefslogtreecommitdiff
path: root/cd-tool.lua
diff options
context:
space:
mode:
Diffstat (limited to 'cd-tool.lua')
-rw-r--r--cd-tool.lua22
1 files changed, 18 insertions, 4 deletions
diff --git a/cd-tool.lua b/cd-tool.lua
index 30ebd34..577b091 100644
--- a/cd-tool.lua
+++ b/cd-tool.lua
@@ -4,9 +4,9 @@
function extract_file(source, dest, mode)
if (mode == nil) then
- source = cdfile(findpath(source))
+ source = cdfile(source)
else
- source = cdfile(findpath(source), mode)
+ source = cdfile(source, mode)
end
dest = Output(dest)
source.copyto(dest)
@@ -26,21 +26,28 @@ function insert_file(source, dest, mode)
end
end
-function display(inp)
+function display(inp, n)
+ local i
if (type(inp) == "string") then
inp = Input(inp)
elseif (type(inp) ~= "table") then
error("Display needs a string or an Input object")
end
+ i = 0
+
while(not inp:isclosed()) do
+ i = i + 1
print(inp:read())
+ if ((n ~= nil) and (i >= n)) then
+ return
+ end
end
end
function pchar(n)
if (not ((n >= 32) and (n <= 127))) then
- n = 46 -- a dot, 0x2e.
+ n = 46 -- aka '.' or 0x2e
end
return hex(n, "%c")
end
@@ -125,6 +132,13 @@ function cdfile(arg1, arg2, arg3, arg4)
if ((type(arg1) ~= "table") or (arg1.cdfile == nil)) then
check_cdutil()
cdutil_implied = true
+ if (type(arg1) == "string") then
+ arg1 = findpath(arg1)
+ end
+ else
+ if (type(arg2) == "string") then
+ arg2 = findpath(arg2)
+ end
end
if ((arg2 == nil) and (arg3 == nil) and (arg4 == nil)) then