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:
parent
719c2f4610
commit
cf88f5e8a4
1 changed files with 0 additions and 21 deletions
21
Nasal/io.nas
21
Nasal/io.nas
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue