summaryrefslogtreecommitdiffstats
path: root/logfiles-model.lua
diff options
context:
space:
mode:
authorTed Trask <ttrask01@yahoo.com>2008-09-03 13:51:14 +0000
committerTed Trask <ttrask01@yahoo.com>2008-09-03 13:51:14 +0000
commiteb36e4c9737dee9dd3aaef56abcfcf6c407bd100 (patch)
treef823409966cb2c8152747236a312cbfe80c7e608 /logfiles-model.lua
parent3f22a6dd4d2336bf0c3409c400faa9f5488f0e32 (diff)
downloadacf-alpine-baselayout-eb36e4c9737dee9dd3aaef56abcfcf6c407bd100.tar.bz2
acf-alpine-baselayout-eb36e4c9737dee9dd3aaef56abcfcf6c407bd100.tar.xz
Added javascript tail functionality to logfiles.
git-svn-id: svn://svn.alpinelinux.org/acf/alpine-baselayout/trunk@1441 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'logfiles-model.lua')
-rw-r--r--logfiles-model.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/logfiles-model.lua b/logfiles-model.lua
index 2ac4f5d..54aceee 100644
--- a/logfiles-model.lua
+++ b/logfiles-model.lua
@@ -76,6 +76,38 @@ get_filedetails = function (path)
return filedetails
end
+tail = function(path, offset)
+ local filename = cfe({ value=path, label="File name", errtxt="File not found" })
+ local filesize = cfe({ value="0", label="File size" })
+ local filecontent = cfe({ type="longtext", label="File content" })
+ local fileoffset = cfe({ value="0", label="File offset" })
+
+ local available_files = get()
+ for i,file in ipairs(available_files.value) do
+ if ( file.value.filename.value == path ) then
+ filename.errtxt = nil
+ local f = io.open(path)
+ if tonumber(offset) then
+ fileoffset.value = offset
+ offset = tonumber(offset)
+ if offset < 0 then
+ f:seek("end", offset)
+ else
+ f:seek("set", offset)
+ end
+ filecontent.value = f:read("*all")
+ filesize.value = f:seek()
+ else
+ filesize.value = f:seek("end")
+ fileoffset.value = filesize.value
+ end
+ f:close()
+ break
+ end
+ end
+
+ return cfe({ type="group", value={filename=filename, filecontent=filecontent, filesize=filesize, fileoffset=fileoffset}, label="Tail Config file details" })
+end
get = function ()
-- These folders (and their subfolers) are going to be listed