1
0
Fork 0

remove is{dir,reg,lnk,sock,fifo,blk,chr}. The vector returned by io.stat()

does now contain the type in element 11.
This commit is contained in:
mfranz 2009-02-15 21:08:55 +00:00
parent 719c2f4610
commit cf88f5e8a4

View file

@ -9,27 +9,6 @@ var readfile = func(file) {
}
# Generates a stat() test routine that is passed the "mode" field
# (stat(...)[2]) from a stat() call (index 2), extracts the IFMT
# subfield and compares it with the given type, assumes S_IFMT ==
# 0xf000.
var _gen_ifmt_test = func(fmt, ifmt) {
func(stat_mode) {
debug.warn("use of deprecated function is" ~ fmt ~ "()");
var i = int(stat_mode / 0x1000);
return ifmt == i - int(i / 0x10) * 0x10;
}
}
# Generate file type test predicates isdir(), isreg(), islnk(), etc.
# Usage: var s = io.stat(filename); # nil -> doesn't exist, broken link
# if (s != nil and io.isdir(s[2])) { ... }
var ifmts = { dir:4, reg:8, lnk:10, sock:12, fifo:1, blk:6, chr:2 };
foreach (var fmt; keys(ifmts))
caller(0)[0]["is" ~ fmt] = _gen_ifmt_test(fmt, ifmts[fmt]);
# Loads Nasal file into namespace and executes it. The namespace
# (module name) is taken from the optional second argument, or
# derived from the Nasal file's name.