aboutsummaryrefslogtreecommitdiff
path: root/isdirectory.tcl
blob: 56396da9beb35c4051ed5ef14549e0fdfd2dcb5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package require Tclpd 0.3.0
package require TclpdLib 0.20
package require tclfile

proc isdirectory::constructor {self args} {
    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 [tclfile::expand_vars [pd::arg 0 symbol]]
    isdirectory::0_bang $self
}

proc isdirectory::0_anything {self args} {
    variable ${self}::filename [tclfile::expand_vars [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 [tclfile::expand_vars [pd::arg 0 symbol]]
}

proc isdirectory::1_anything {self args} {
    variable ${self}::filename [tclfile::expand_vars [tclfile::make_symbol $args]]
}

pd::class isdirectory