Changeset 924
- Timestamp:
- 08/14/13 16:11:16 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libIGCM/libIGCM_debug/libIGCM_debug.ksh
r917 r924 86 86 #D-function IGCM_debug_sizeOfTabContent 87 87 #D- * Purpose: Give sumed size of a list of files 88 #D- * Usage: IGCM_debug_sizeOfTabContent entityList destination 89 #D- * where entityList is a list of files or directory 90 #D- * where dest is either a directory or a file name 88 91 function IGCM_debug_sizeOfTabContent 89 92 { 90 typeset dm_liste ifile sizeFile sizeKo sizeMo 91 eval set +A dm_liste \${${1}} 92 sizeKo=0 93 for ((i = 0; i < ${#dm_liste[*]}; i += 1)) ; do 94 # echo "dm_liste[$i]=${dm_liste[$i]}" 95 # we want to compute the size from local path (not from archive ...) 96 # remove path /home/login/../ from dm_liste elements 97 if [ -f ${dm_liste[$i]##/*/} ] ; then 98 ifile=${dm_liste[$i]##/*/} 99 elif [ -f ${2} ] ; then 100 ifile=${2} 101 elif [ -f $2/${dm_liste[$i]##/*/} ] ; then 102 ifile=${2}/${dm_liste[$i]##/*/} 103 fi 104 sizeFile=$( du --apparent-size -k ${ifile} | awk {'print $1'} ) 105 sizeKo=$(( $sizeKo + $sizeFile )) 93 typeset entityListe destination iEntity sizeKo sumSizeKo sumSizeMo 94 95 eval set +A entityListe \${${1}} 96 destination=${2} 97 sumSizeKo=0 98 99 # Here we will try to compute size (file or directory size) from local path and not from archive. 100 for ((i = 0; i < ${#entityListe[*]}; i += 1)) ; do 101 if [ -f ${entityListe[$i]##/*/} ] ; then 102 # One file or a bunch of files has been copied without renaming 103 # remove path /home/login/../ from entityListe elements 104 iEntity=${entityListe[$i]##/*/} 105 elif [ -f ${destination} ] ; then 106 # a file has been copied and rename 107 iEntity=${destination} 108 elif [ -f ${destination}/${entityListe[$i]##/*/} ] ; then 109 # a copy in a directory but not in ${PWD} 110 iEntity=${destination}/${entityListe[$i]##/*/} 111 elif [ -d ${entityListe[$i]} ] ; then 112 # directory has been copied from non remote place 113 iEntity=${entityListe[$i]} 114 elif [ -d ${destination}/${entityListe[$i]##/*/} ] ; then 115 # directory has been copied from remote archive and not rename 116 iEntity=${destination}/${entityListe[$i]##/*/} 117 elif [ -d ${destination} ] ; then 118 # directory has been copied from remote archive and rename 119 iEntity=${destination} 120 fi 121 sizeKo=$( du --apparent-size -k ${iEntity} | awk {'print $1'} ) 122 sumSizeKo=$(( $sumSizeKo + $sizeKo )) 106 123 done 107 s izeMo=$( echo "scale=6;${sizeKo}/1024" | bc )108 echo "${s izeKo}|${sizeMo}"124 sumSizeMo=$( echo "scale=6;${sumSizeKo}/1024" | bc ) 125 echo "${sumSizeKo}|${sumSizeMo}" 109 126 } 110 127 … … 313 330 # Classical copy (only files are given to IGCM_sys_Cp as options) 314 331 IGCM_sys_Cp) 315 instrumentation=true 332 instrumentation=true 316 333 # All but the latest 317 334 fileList=${arguments[*]:0:${#arguments[*]}-1} … … 321 338 dest=${arguments[${#arguments[*]}-1]} 322 339 # Size of file whose name are stored in a list 323 entitySize=$( IGCM_debug_sizeOfTabContent fileList $ dest)340 entitySize=$( IGCM_debug_sizeOfTabContent fileList ${dest} ) 324 341 ;; 325 342 … … 327 344 IGCM_sys_Get_Master|IGCM_sys_Get_Dir) 328 345 instrumentation=true 329 if [ ${#arguments[*]} -eq 2 ] ; then 330 source=${arguments[0]} 331 dest=${arguments[1]} 332 # Size of file whose name are stored in a variable 333 entitySize=$( IGCM_debug_sizeOfTabContent source ) 334 fi 346 source=${arguments[0]} 347 dest=${arguments[1]} 348 # Size of file whose name are stored in a variable 349 entitySize=$( IGCM_debug_sizeOfTabContent source ${dest} ) 335 350 ;; 336 351
Note: See TracChangeset
for help on using the changeset viewer.