From 44d457f6e8e4427774bd6316c05818c62169359b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 14 Nov 2011 05:52:36 +0000 Subject: added all objects from Tcl's file cmd that output a truth 0/1 value svn path=/trunk/externals/tclfile/; revision=15743 --- executable.tcl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ isdirectory.tcl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ isfile.tcl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ owned.tcl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ readable.tcl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ writable.tcl | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 306 insertions(+) create mode 100644 executable.tcl create mode 100644 isdirectory.tcl create mode 100644 isfile.tcl create mode 100644 owned.tcl create mode 100644 readable.tcl create mode 100644 writable.tcl diff --git a/executable.tcl b/executable.tcl new file mode 100644 index 0000000..f196cdc --- /dev/null +++ b/executable.tcl @@ -0,0 +1,51 @@ +package require Tclpd 0.3.0 +package require TclpdLib 0.20 +package require tclfile + +proc executable::constructor {self args} { + if {![namespace exists $self]} { + namespace eval $self {} + } + variable ${self}::current_canvas [canvas_getcurrent] + # set to blank so the var always exists + variable ${self}::filename {} + + # add second inlet (first created by default) + pd::add_inlet $self list + + # add outlet + pd::add_outlet $self list +} + +# HOT inlet -------------------------------------------------------------------- +proc executable::0_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] + executable::0_bang $self +} + +proc executable::0_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] + executable::0_bang $self +} + +proc executable::0_bang {self} { + variable ${self}::current_canvas + variable ${self}::filename + if {[file pathtype $filename] eq "absolute"} { + pd::outlet $self 0 float [file executable $filename] + } else { + set dir [canvas_getdir $current_canvas] + pd::outlet $self 0 float [file executable [file join $dir $filename]] + } +} + +# COLD inlet ------------------------------------------------------------------- +proc executable::1_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] +} + +proc executable::1_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] +} + +pd::class executable diff --git a/isdirectory.tcl b/isdirectory.tcl new file mode 100644 index 0000000..6cdc175 --- /dev/null +++ b/isdirectory.tcl @@ -0,0 +1,51 @@ +package require Tclpd 0.3.0 +package require TclpdLib 0.20 +package require tclfile + +proc isdirectory::constructor {self args} { + if {![namespace exists $self]} { + namespace eval $self {} + } + variable ${self}::current_canvas [canvas_getcurrent] + # set to blank so the var always exists + variable ${self}::filename {} + + # add second inlet (first created by default) + pd::add_inlet $self list + + # add outlet + pd::add_outlet $self list +} + +# HOT inlet -------------------------------------------------------------------- +proc isdirectory::0_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] + isdirectory::0_bang $self +} + +proc isdirectory::0_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] + isdirectory::0_bang $self +} + +proc isdirectory::0_bang {self} { + variable ${self}::current_canvas + variable ${self}::filename + if {[file pathtype $filename] eq "absolute"} { + pd::outlet $self 0 float [file isdirectory $filename] + } else { + set dir [canvas_getdir $current_canvas] + pd::outlet $self 0 float [file isdirectory [file join $dir $filename]] + } +} + +# COLD inlet ------------------------------------------------------------------- +proc isdirectory::1_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] +} + +proc isdirectory::1_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] +} + +pd::class isdirectory diff --git a/isfile.tcl b/isfile.tcl new file mode 100644 index 0000000..ad58ec1 --- /dev/null +++ b/isfile.tcl @@ -0,0 +1,51 @@ +package require Tclpd 0.3.0 +package require TclpdLib 0.20 +package require tclfile + +proc isfile::constructor {self args} { + if {![namespace exists $self]} { + namespace eval $self {} + } + variable ${self}::current_canvas [canvas_getcurrent] + # set to blank so the var always exists + variable ${self}::filename {} + + # add second inlet (first created by default) + pd::add_inlet $self list + + # add outlet + pd::add_outlet $self list +} + +# HOT inlet -------------------------------------------------------------------- +proc isfile::0_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] + isfile::0_bang $self +} + +proc isfile::0_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] + isfile::0_bang $self +} + +proc isfile::0_bang {self} { + variable ${self}::current_canvas + variable ${self}::filename + if {[file pathtype $filename] eq "absolute"} { + pd::outlet $self 0 float [file isfile $filename] + } else { + set dir [canvas_getdir $current_canvas] + pd::outlet $self 0 float [file isfile [file join $dir $filename]] + } +} + +# COLD inlet ------------------------------------------------------------------- +proc isfile::1_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] +} + +proc isfile::1_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] +} + +pd::class isfile diff --git a/owned.tcl b/owned.tcl new file mode 100644 index 0000000..7255709 --- /dev/null +++ b/owned.tcl @@ -0,0 +1,51 @@ +package require Tclpd 0.3.0 +package require TclpdLib 0.20 +package require tclfile + +proc owned::constructor {self args} { + if {![namespace exists $self]} { + namespace eval $self {} + } + variable ${self}::current_canvas [canvas_getcurrent] + # set to blank so the var always exists + variable ${self}::filename {} + + # add second inlet (first created by default) + pd::add_inlet $self list + + # add outlet + pd::add_outlet $self list +} + +# HOT inlet -------------------------------------------------------------------- +proc owned::0_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] + owned::0_bang $self +} + +proc owned::0_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] + owned::0_bang $self +} + +proc owned::0_bang {self} { + variable ${self}::current_canvas + variable ${self}::filename + if {[file pathtype $filename] eq "absolute"} { + pd::outlet $self 0 float [file owned $filename] + } else { + set dir [canvas_getdir $current_canvas] + pd::outlet $self 0 float [file owned [file join $dir $filename]] + } +} + +# COLD inlet ------------------------------------------------------------------- +proc owned::1_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] +} + +proc owned::1_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] +} + +pd::class owned diff --git a/readable.tcl b/readable.tcl new file mode 100644 index 0000000..d83b420 --- /dev/null +++ b/readable.tcl @@ -0,0 +1,51 @@ +package require Tclpd 0.3.0 +package require TclpdLib 0.20 +package require tclfile + +proc readable::constructor {self args} { + if {![namespace exists $self]} { + namespace eval $self {} + } + variable ${self}::current_canvas [canvas_getcurrent] + # set to blank so the var always exists + variable ${self}::filename {} + + # add second inlet (first created by default) + pd::add_inlet $self list + + # add outlet + pd::add_outlet $self list +} + +# HOT inlet -------------------------------------------------------------------- +proc readable::0_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] + readable::0_bang $self +} + +proc readable::0_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] + readable::0_bang $self +} + +proc readable::0_bang {self} { + variable ${self}::current_canvas + variable ${self}::filename + if {[file pathtype $filename] eq "absolute"} { + pd::outlet $self 0 float [file readable $filename] + } else { + set dir [canvas_getdir $current_canvas] + pd::outlet $self 0 float [file readable [file join $dir $filename]] + } +} + +# COLD inlet ------------------------------------------------------------------- +proc readable::1_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] +} + +proc readable::1_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] +} + +pd::class readable diff --git a/writable.tcl b/writable.tcl new file mode 100644 index 0000000..e300f28 --- /dev/null +++ b/writable.tcl @@ -0,0 +1,51 @@ +package require Tclpd 0.3.0 +package require TclpdLib 0.20 +package require tclfile + +proc writable::constructor {self args} { + if {![namespace exists $self]} { + namespace eval $self {} + } + variable ${self}::current_canvas [canvas_getcurrent] + # set to blank so the var always exists + variable ${self}::filename {} + + # add second inlet (first created by default) + pd::add_inlet $self list + + # add outlet + pd::add_outlet $self list +} + +# HOT inlet -------------------------------------------------------------------- +proc writable::0_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] + writable::0_bang $self +} + +proc writable::0_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] + writable::0_bang $self +} + +proc writable::0_bang {self} { + variable ${self}::current_canvas + variable ${self}::filename + if {[file pathtype $filename] eq "absolute"} { + pd::outlet $self 0 float [file writable $filename] + } else { + set dir [canvas_getdir $current_canvas] + pd::outlet $self 0 float [file writable [file join $dir $filename]] + } +} + +# COLD inlet ------------------------------------------------------------------- +proc writable::1_symbol {self args} { + variable ${self}::filename [pd::arg 0 symbol] +} + +proc writable::1_anything {self args} { + variable ${self}::filename [tclfile::make_symbol $args] +} + +pd::class writable -- cgit v1.2.1