Tcl Source Code

Artifact [088c9b9356]
Login

Artifact 088c9b935613fd903f5b782af585cbfdffc51c60:

Attachment "test.tcl" to ticket [5bfe3de008] added by andy 2017-08-08 22:08:09.
#!/bin/bash
# This comment hides the next line from the Tcl interpreter.\
exec "$(dirname "$0")/util/tclkit" "$0" "$@"

lappend auto_path lib
package require Tcl 8.6
package require tcl::chan::variable
package require vfs

vfs::filesystem mount /test {apply {{operation root relative actual args} {
    if {$relative ne "foo"} {
        vfs::filesystem posixerror $::vfs::posix(ENOENT)
    }
    switch $operation {
    access {
        return 1
    } open {
        tcl::chan::variable ::foo
    } stat {
        set now [clock seconds]
        set stat {mode 0777 dev -1 ino -1 uid -1 gid -1 nlink 1 type file}
        dict set stat name $relative
        dict set stat atime $now
        dict set stat ctime $now
        dict set stat mtime $now
        dict set stat size [string length $::foo]
        return $stat
    }}
}}}

set foo {puts hello}
puts [string length $foo]
source /test/foo
puts [string length $foo]

# vim: set sts=4 sw=4 tw=80 et ft=tcl: