summaryrefslogtreecommitdiff
path: root/appl/cmd/newer.b
diff options
context:
space:
mode:
authorCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
committerCharles.Forsyth <devnull@localhost>2006-12-22 17:07:39 +0000
commit37da2899f40661e3e9631e497da8dc59b971cbd0 (patch)
treecbc6d4680e347d906f5fa7fca73214418741df72 /appl/cmd/newer.b
parent54bc8ff236ac10b3eaa928fd6bcfc0cdb2ba46ae (diff)
20060303a
Diffstat (limited to 'appl/cmd/newer.b')
-rw-r--r--appl/cmd/newer.b36
1 files changed, 36 insertions, 0 deletions
diff --git a/appl/cmd/newer.b b/appl/cmd/newer.b
new file mode 100644
index 00000000..ce0f743d
--- /dev/null
+++ b/appl/cmd/newer.b
@@ -0,0 +1,36 @@
+implement Newer;
+
+#
+# test if a file is up to date
+#
+
+include "sys.m";
+
+include "draw.m";
+
+Newer: module
+{
+ init: fn(nil: ref Draw->Context, nil: list of string);
+};
+
+init(nil: ref Draw->Context, args: list of string)
+{
+ sys := load Sys Sys->PATH;
+ if(len args != 3){
+ sys->fprint(sys->fildes(2), "usage: newer newfile oldfile\n");
+ raise "fail:usage";
+ }
+ args = tl args;
+ (ok1, d1) := sys->stat(hd args);
+ if(ok1 < 0)
+ raise sys->sprint("fail:new:%r");
+ if(d1.mode & Sys->DMDIR)
+ raise "fail:new:directory";
+ (ok2, d2) := sys->stat(hd tl args);
+ if(ok2 < 0)
+ raise sys->sprint("fail:old:%r");
+ if(d2.mode & Sys->DMDIR)
+ raise "fail:old:directory";
+ if(d2.mtime > d1.mtime)
+ raise "fail:older";
+}