diff options
author | Mika Havela <mika.havela@gmail.com> | 2008-01-15 15:56:36 +0000 |
---|---|---|
committer | Mika Havela <mika.havela@gmail.com> | 2008-01-15 15:56:36 +0000 |
commit | ef25e34bac3a62c6570f49f1b8db1fb63c5a9659 (patch) | |
tree | c76a8a9e0c1ed360869653abade1b84c776de923 /lib | |
parent | 8e2fe1673cf1a4330e6f210c366ca505c13b09c2 (diff) | |
download | acf-core-ef25e34bac3a62c6570f49f1b8db1fb63c5a9659.tar.bz2 acf-core-ef25e34bac3a62c6570f49f1b8db1fb63c5a9659.tar.xz |
Added function that does almost the same as posix.stat, but instead writes human readable.
git-svn-id: svn://svn.alpinelinux.org/acf/core/trunk@577 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'lib')
-rw-r--r-- | lib/fs.lua | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -118,3 +118,20 @@ function find ( what, where ) end end +-- This function does almost the same as posix.stat, but instead it writes the output human readable. +function stat ( path ) + local filedetails = posix.stat(path) + filedetails["ctime"]=os.date("%c", filedetails["ctime"]) + filedetails["mtime"]=os.date("%c", filedetails["mtime"]) + filedetails["path"]=path + if ( filedetails["size"] > 1073741824 ) then + filedetails["size"]=((filedetails["size"]/1073741824) - (filedetails["size"]/1073741824%0.1)) .. "G" + elseif ( filedetails["size"] > 1048576 ) then + filedetails["size"]=((filedetails["size"]/1048576) - (filedetails["size"]/1048576%0.1)) .. "M" + elseif ( filedetails["size"] > 1024 ) then + filedetails["size"]=((filedetails["size"]/1024) - (filedetails["size"]/1024%0.1)) .. "k" + else + filedetails["size"]=filedetails["size"] + end + return filedetails +end |