From a8c4df339f0913eb92ed2e57a0384a0cf401139e Mon Sep 17 00:00:00 2001 From: cas Date: Fri, 8 Sep 2000 15:32:13 +0000 Subject: [PATCH] No comments --- src/WOKTclLib/wutils.tcl | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/src/WOKTclLib/wutils.tcl b/src/WOKTclLib/wutils.tcl index 90e4812..747c557 100755 --- a/src/WOKTclLib/wutils.tcl +++ b/src/WOKTclLib/wutils.tcl @@ -330,6 +330,37 @@ proc wokUtils:FILES:DirMapToProc { d TclFile ProcName } { return -1 } } +;# +;# 1.Scan each element of liste +;# 2.For each element e: +;# substr from e of of the string of pathliste +;# Create a map indexed by the common roots +;# Each entry contains a list of file name that begins under this entry. +;# 3.Returns the list of element where substr failed. +;# CAUTION : add a slash at the end of pathes in pathliste so entries will be directly usable +;# tt [list /adv_11/KAS/C30/ref/ /adv_11/KAS/C30/UpdateC31/] FOC.lst +;# Easy for preparing Gnu tar command using option --from-file. +;# +proc wokUtils:FILES:RelativePathes { pathliste liste map } { + upvar $map TLOC + set ret {} + foreach e [wokUtils:FILES:FileToList $liste] { + set yy [wokUtils:EASY:trytrim $pathliste $e] + if { $yy != {} } { + set yy0 [lindex $yy 0] + if [info exists TLOC($yy0)] { + set li $TLOC($yy0) + lappend li [lindex $yy 1] + set TLOC($yy0) $li + } else { + set TLOC($yy0) [lindex $yy 1] + } + } else { + lappend ret $e + } + } + return $ret +} # # Compare contents of directory d with a previous state. # (previous state in file $d/__PreviousState.tcl) @@ -457,6 +488,26 @@ proc wokUtils:FILES:AppendListToFile { liste path } { return 1 } } +;# +;# substr "" in elements of lp (path part) in fname +;# returns a liste of 2 elements : e1 e2 +;# e1 1 st element that match +;# e2 fname after substr example: +;# tt:parseloc {/adv_11/KAS/C30/ref/ /adv_11/KAS/C30/UpdateC31/} /adv_11/KAS/C30/UpdateC31/README +;# => /adv_11/KAS/C30/UpdateC31/ README +;# tt:parseloc {/adv_11/KAS/C30/ref/ /adv_11/KAS/C30/UpdateC31/} /adv_11/KAS/C30/ref/src/gp/gp_Pnt.cxx +;# => /adv_11/KAS/C30/ref/ src/gp/gp_Pnt.cxx +;# +proc wokUtils:EASY:trytrim { lp pname } { + set res {} + foreach p $lp { + if [regsub $p $pname "" dst] { + set res [list $p $dst] + break + } + } + return $res +} # # Replace s1 by s2 in fin and write result in fout # return 1 if substitution was performed. -- 2.39.5