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 |
import strutils, os, times import ../core/parser, ../core/value, ../core/interpreter, ../core/utils, ../core/fileutils proc fs_module*(i: In) = i.define("fs") .symbol("mtime") do (i: In): var s: MinValue i.reqStringLike s i.push s.getString.getLastModificationTime.toSeconds.newVal .symbol("atime") do (i: In): var s: MinValue i.reqStringLike s i.push s.getString.getLastAccessTime.toSeconds.newVal .symbol("ctime") do (i: In): var s: MinValue i.reqStringLike s i.push s.getString.getCreationTime.toSeconds.newVal .symbol("hidden?") do (i: In): var s: MinValue i.reqStringLike s i.push s.getString.isHidden.newVal .symbol("fsize") do (i: In): var s: MinValue i.reqStringLike s i.push s.getString.getFileSize.newVal .symbol("fstats") do (i: In): var s: MinValue i.reqStringLike s let fi = s.getString.getFileInfo var info = newSeq[MinValue](0).newVal(i.scope) info.qVal.add @["name".newSym, s].newVal(i.scope) info.qVal.add @["device".newSym, fi.id.device.newVal].newVal(i.scope) info.qVal.add @["file".newSym, fi.id.file.newVal].newVal(i.scope) info.qVal.add @["type".newSym, fi.kind.filetype.newVal].newVal(i.scope) info.qVal.add @["size".newSym, fi.size.newVal].newVal(i.scope) info.qVal.add @["permissions".newSym, fi.permissions.unixPermissions.newVal].newVal(i.scope) info.qVal.add @["nlinks".newSym, fi.linkCount.newVal].newVal(i.scope) info.qVal.add @["ctime".newSym, fi.creationTime.toSeconds.newVal].newVal(i.scope) info.qVal.add @["atime".newSym, fi.lastAccessTime.toSeconds.newVal].newVal(i.scope) info.qVal.add @["mtime".newSym, fi.lastWriteTime.toSeconds.newVal].newVal(i.scope) i.push info .symbol("ftype") do (i: In): var s: MinValue i.reqStringLike s i.push s.getString.getFileInfo.kind.filetype.newVal .symbol("fperms") do (i: In): var s: MinValue i.reqStringLike s i.push s.getString.getFilePermissions.unixPermissions.newVal .finalize() |