cmdr
Check-in [e7f547d6aa]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cmdr::validate::common - Consolidated multiple copies of "OkDir" in cmdr::validate into a single shared helper command "ok-directory".
Timelines: family | ancestors | descendants | both | more-vtypes
Files: files | file ages | folders
SHA1: e7f547d6aa1bf5d405da129a201673e9c83b75bf
User & Date: andreask 2014-03-13 18:34:01.679
Context
2014-03-13
18:36
cmdr::validate - Replaced all uses of "OkDir" with the shared "ok-directory". Changed the "rw*" types to allow missing file/dir/path like the "w*" types.. Fixed the fail messages for "wfile" and "wchan". check-in: 62fbd92a1b user: andreask tags: more-vtypes
18:34
cmdr::validate::common - Consolidated multiple copies of "OkDir" in cmdr::validate into a single shared helper command "ok-directory". check-in: e7f547d6aa user: andreask tags: more-vtypes
2014-02-19
19:39
Modified the checks for wfile/wchan to allow non-existing files which can be created (per permissions). check-in: 9ab661bcd1 user: andreask tags: more-vtypes
Changes
Unified Diff Ignore Whitespace Patch
Changes to vcommon.tcl.
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

namespace eval ::cmdr::validate {
    namespace export common
    namespace ensemble create
}

namespace eval ::cmdr::validate::common {
    namespace export fail complete-enum complete-glob
    namespace ensemble create
}

# # ## ### ##### ######## ############# #####################

debug define cmdr/validate/common
debug level  cmdr/validate/common







|







33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

namespace eval ::cmdr::validate {
    namespace export common
    namespace ensemble create
}

namespace eval ::cmdr::validate::common {
    namespace export fail complete-enum complete-glob ok-directory
    namespace ensemble create
}

# # ## ### ##### ######## ############# #####################

debug define cmdr/validate/common
debug level  cmdr/validate/common
102
103
104
105
106
107
108
109
























110
111
112
113
	if {![{*}$filter $path]} continue
	lappend candidates $path
    }

    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
    return $candidates
}

























# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate::common 1.1
return








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>


|

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
	if {![{*}$filter $path]} continue
	lappend candidates $path
    }

    debug.cmdr/validate/common {= [join $candidates "\n= "]} 10
    return $candidates
}

proc ::cmdr::validate::common::ok-directory {path} {
    if {![file exists $path]} {

	# The directory is allowed to not exist if its parent
	# directory exists and is writable.
	# Note: Prevent us from walking up the chain if the directory
	# has no parent.
	# Note 2: Switch to absolute notation if path is the relative
	# name of the CWD (i.e. ".").
	if {$path eq "."} {
	    set path [pwd]
	}
	set up [file dirname $path]
	if {$up eq $path} {
	    # Reached root (/, x:, x:/), found it missing, stop & fail.
	    return 0
	}
	return [ok-directory $up]
    }
    if {![file isdirectory $path]} {return 0}
    if {![file writable    $path]} {return 0}
    return 1
}

# # ## ### ##### ######## ############# #####################
## Ready
package provide cmdr::validate::common 1.2
return