Go Back   FlashFXP Forums > > > >

! Other Scripts Support Support for all other scripts...

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-19-2003, 05:56 AM   #1
darkone
Disabled
FlashFXP Registered User
ioFTPD Administrator
 
darkone's Avatar
 
Join Date: Dec 2001
Posts: 2,230
Default [iTCL] globbing example

Press quote to get more readable version of source..

set mtab "d:/ioFTPD/etc/default.vfs"
set gpath "/home/"

# Load mount table
if { [catch { mountfile open $mtab }] != 0 } {
putlog "Warning! Script failed to load $mtab"
return 1
}

# Resolve root (sanity check)
if { [catch { set path [resolve pwd $gpath]}] != 0 } {
putlog "Warning! Failed to resolve $gpath"
return 1
}
unset path


# Globber proc
proc symglobber { vpath depth } {

# Limit max globbing depth
if { [incr depth] > 5 } { return 1 }
# Resolve path
if { [catch { set path [resolve pwd $vpath]}] != 0 } { return 1 }
# Resolve link
if { [catch { set result [glob -types d $path/*]}] != 0 } { return 1 }
set lpath [string length $path]

foreach item $result {

# Get context
if { [catch { set ldest [vfs chattr $item 1]}] != 0 } { return 1 }

# Check context
if { "$ldest" != "(null)" } {
# Resolve destination
if { [string index $ldest 0] == "/" } {
# Link is not relative to current directory
if { [catch { set dpath [resolve pwd $ldest]}] != 0 } { return 1 }
} else {
if { [catch { set dpath [resolve $vpath/$ldest]}] != 0 } { return 1 }
}
# Delete inexistant links
if {$dpath == "" || [file exists $dpath] == 0} {
catch { file delete $item/.ioFTPD }
if { [catch { file delete $item}] == 0} {
iputs "Removed $item"
} else {
iputs "Unexpected error while deleting $item"
}
}

} else {
# Get new virtual path
set litem [string length $item]
set newvpath $vpath[string range $item $lpath end]

# Glob subdirectory
symglobber $newvpath $depth
}
}
}


symglobber $gpath 0
darkone is offline   Reply With Quote
Old 11-20-2003, 11:37 PM   #2
b>d>>s
Senior Member
 
Join Date: Feb 2003
Posts: 488
Default

http://inferno.slug.org/cgi-bin/wiki?Du_In_Tcl

thats cool too. ^^ quite handy.
b>d>>s is offline   Reply With Quote
Reply

Tags
$item, path, return, set, [catch

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT -5. The time now is 08:17 PM.

Parts of this site powered by vBulletin Mods & Addons from DragonByte Technologies Ltd. (Details)