Move pathname and basename utility functions to extra_utility
This makes them generally available to SICS (and it's early)
This commit is contained in:
@@ -1,3 +1,23 @@
|
||||
# utility functions like basename/dirname in bash (dcl)
|
||||
proc basename {node} {
|
||||
set point [string last "/" $node]
|
||||
if { $point < 0 } {
|
||||
return $node
|
||||
} else {
|
||||
incr point
|
||||
return "[string range $node $point end]"
|
||||
}
|
||||
}
|
||||
proc pathname {node} {
|
||||
set point [string last "/" $node]
|
||||
if { $point < 0 } {
|
||||
return ""
|
||||
} else {
|
||||
incr point -1
|
||||
return "[string range $node 0 $point]"
|
||||
}
|
||||
}
|
||||
|
||||
# Many of these functions are also useful in test and debug code
|
||||
# running on an external Tcl interpreter.
|
||||
set errorInfo ""
|
||||
|
||||
Reference in New Issue
Block a user