parent
5dccc81116
commit
f3d30c81c5
2 changed files with 24 additions and 0 deletions
|
@ -8,6 +8,7 @@ srcDir = "src"
|
|||
bin = @["b64d",
|
||||
"b64e",
|
||||
"glog",
|
||||
"latest",
|
||||
"bcat"]
|
||||
binDir = "bin"
|
||||
|
||||
|
|
23
src/latest.nim
Normal file
23
src/latest.nim
Normal file
|
@ -0,0 +1,23 @@
|
|||
import std/[os, posix, posix_utils]
|
||||
|
||||
proc `<`(t1, t2: Time): bool {.borrow.}
|
||||
|
||||
var
|
||||
params = commandLineParams()
|
||||
latest: (string, Time)
|
||||
|
||||
if params.len < 1:
|
||||
params = @[getCurrentDir()]
|
||||
|
||||
for dir in params:
|
||||
for file in walkDir dir:
|
||||
let
|
||||
s = stat file.path
|
||||
tim =
|
||||
when StatHasNanoseconds: s.st_mtim.tv_sec
|
||||
else: s.st_mtime
|
||||
if latest[1] < tim:
|
||||
latest = (file.path, tim)
|
||||
|
||||
stdout.write latest[0]
|
||||
stdout.flushFile
|
Loading…
Reference in a new issue