lib/min_fs.nim
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
import strutils, os, times import ../core/parser, ../core/value, ../core/interpreter, ../core/utils, ../core/fileutils proc fs_module*(i: In) = let def = i.define() def.symbol("mtime") do (i: In): let vals = i.expect("'sym") let s = vals[0] i.push s.getString.getLastModificationTime.toUnix.newVal def.symbol("atime") do (i: In): let vals = i.expect("'sym") let s = vals[0] i.push s.getString.getLastAccessTime.toUnix.newVal def.symbol("ctime") do (i: In): let vals = i.expect("'sym") let s = vals[0] i.push s.getString.getCreationTime.toUnix.newVal def.symbol("hidden?") do (i: In): let vals = i.expect("'sym") let s = vals[0] i.push s.getString.isHidden.newVal def.symbol("fsize") do (i: In): let vals = i.expect("'sym") let s = vals[0] i.push s.getString.getFileSize.newVal def.symbol("fstats") do (i: In): let vals = i.expect("'sym") let s = vals[0] let fi = s.getString.getFileInfo var info = newSeq[MinValue](0).newVal(i.scope) info.qVal.add @["name".newVal, s].newVal(i.scope) info.qVal.add @["device".newVal, fi.id.device.BiggestInt.newVal].newVal(i.scope) info.qVal.add @["file".newVal, fi.id.file.BiggestInt.newVal].newVal(i.scope) info.qVal.add @["type".newVal, fi.kind.filetype.newVal].newVal(i.scope) info.qVal.add @["size".newVal, fi.size.newVal].newVal(i.scope) info.qVal.add @["permissions".newVal, fi.permissions.unixPermissions.newVal].newVal(i.scope) info.qVal.add @["nlinks".newVal, fi.linkCount.newVal].newVal(i.scope) info.qVal.add @["ctime".newVal, fi.creationTime.toUnix.newVal].newVal(i.scope) info.qVal.add @["atime".newVal, fi.lastAccessTime.toUnix.newVal].newVal(i.scope) info.qVal.add @["mtime".newVal, fi.lastWriteTime.toUnix.newVal].newVal(i.scope) i.push info def.symbol("ftype") do (i: In): let vals = i.expect("'sym") let s = vals[0] i.push s.getString.getFileInfo.kind.filetype.newVal def.symbol("fperms") do (i: In): let vals = i.expect("'sym") let s = vals[0] i.push s.getString.getFilePermissions.unixPermissions.newVal def.finalize("fs") |