Documentation
¶
Overview ¶
Package fsmod is the native module "fs": directories and files of the local file system (TODO.md Q61).
use fs;
for (local e in fs::readdir(".")) println(e["name"], e["dir"] ? "/" : e["size"]);
fs::walk("src", fn(path, e) { if (fs::ext(path) == ".kkl") println(path); });
An entry is a map: name, size, dir, link, mode and time (a time::Time). What fails is an IOError. Symbolic links are not followed by walk. fs::open gives an fs::File (file.go).
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var File = &native.Class{ Name: "File", Methods: map[string]value.NativeMethod{ "readline": method("readline", 0, 0, readline), "read": method("read", 0, 1, read), "write": method("write", 1, -1, write), "print": method("print", 0, -1, printer("")), "println": method("println", 0, -1, printer("\n")), "seek": method("seek", 1, 2, seek), "tell": method("tell", 0, 0, tell), "truncate": method("truncate", 0, 1, truncate), "lock": method("lock", 0, 2, lock), "unlock": method("unlock", 0, 0, unlock), "flush": method("flush", 0, 0, flush), "close": method("close", 0, 0, closeFile), "iter": method("iter", 0, 0, lines), "text": method("text", 0, 0, text), "closed": method("closed", 0, 0, func(a native.Args, env value.Env, f *file) (value.Value, error) { return value.MakeBool(f.closed), nil }), "name": method("name", 0, 0, func(a native.Args, env value.Env, f *file) (value.Value, error) { if f.mem != nil { return value.NilValue, nil } return value.MakeString(f.name), nil }), "mode": method("mode", 0, 0, func(a native.Args, env value.Env, f *file) (value.Value, error) { return value.MakeString(f.mode), nil }), }, Show: func(o *value.ObjectObj) string { f := o.State.(*file) switch { case f.std != 0: return "fs::File(" + f.name + ")" case f.mem != nil && f.closed: return "fs::File(<memory>, closed)" case f.mem != nil: return fmt.Sprintf("fs::File(<memory>, %d bytes)", len(f.mem.data)) case f.closed: return fmt.Sprintf("fs::File(%q, closed)", f.name) } return fmt.Sprintf("fs::File(%q, %q)", f.name, f.mode) }, }
File is the class fs::File. It has no constructor: files come from fs::open and the standard streams.
Functions ¶
func ModeString ¶
ModeString is mode as ls shows it: "-rw-r--r--", "drwxr-xr-x", "lrwxrwxrwx"; s, S and t, T for setuid, setgid and sticky.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.