aboutsummaryrefslogtreecommitdiff
path: root/isdirectory.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'isdirectory.tcl')
-rw-r--r--isdirectory.tcl51
1 files changed, 51 insertions, 0 deletions
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