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:
Douglas Clowes
2014-01-30 14:52:28 +11:00
parent 91d0dc86f5
commit 3abc6c9e60
5 changed files with 20 additions and 78 deletions

View File

@@ -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 ""