return_ext_file - return file of specified extension presents in a tt_ml list
tt = return_ext_file(tt_ml,ext)
- tt_ml : tt_ml master_list. (see return_master_list)
- ext : string. the extension of file to find in the tt_ml list
- tt : vector of strings. the list of the file names of extension ext
//return_ext_file
//fonction qui cherche les fichiers d'extension ext
//dans une liste principale
//Entrée : tt_ml : une liste principale (voir return_master_list)
// ext : un vecteur chaîne d'extensions finales de fichier
// (ex ext='sci', ext='cos', mais aussi ext='monfichier.sci')
//Sortie : tt un vecteur de taille 2 contenant
// le chemin des fichiers cherchés et le nom du fichier
function tt=return_ext_file(tt_ml,ext)
//doit faire faire sur type of ext
a=length(ext)
tt=[];
p=size(tt_ml); //cherche dans toute l'arborescence
l=0
for i=1:p
for j=1:size(tt_ml(i)) //cherche dans tous les répertoires
for k=1:size(tt_ml(i)(j)(2),1) //uniquement les fichiers
tt_nam=tt_ml(i)(j)(2)(k);
//for m=1:size(a,1) //meilleur temps si l'on utilise ext de taille 1
if length(tt_nam)>(a-1) then
//ierr=execstr('ok=part(tt_nam,length(tt_nam)-(a-1):length(tt_nam))==ext','errcatch');
//if ierr==0 & ok==%t then
if part(tt_nam,length(tt_nam)-(a-1):length(tt_nam))==ext then
//b=strindex(tt_ml(i)(j)(2)(k),ext);
//if b(size(b,'*'))==length(tt_ml(i)(j)(2)(k))-(a-1) then
l=l+1;
tt_tmp=[tt_ml(i)(j)(1),tt_ml(i)(j)(2)(k)];
tt=[tt;tt_tmp];
end
//end
end
end
end
end
printf("Found %d file(s) with %s extension\n",l,ext);
endfunction
IRCOM Group
Alan Layec