]> Creatis software - bbtk.git/commitdiff
#2912 BBTK Feature New Normal - FilesFromDirectory box package std
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 11 Apr 2016 12:19:38 +0000 (14:19 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Mon, 11 Apr 2016 12:19:38 +0000 (14:19 +0200)
packages/std/src/bbstdFilesFromDirectory.cxx
packages/std/src/bbstdFilesFromDirectory.h

index 61fb34c9c5a4e6a2b4bd93446c9367faa5a7e6d7..6712c8cca4230ee8a6008098204ff4d8d099d93c 100644 (file)
@@ -269,12 +269,39 @@ void FilesFromDirectory::CleanFilenames( std::string basePath )
 {
        std::string tmpString;
        int i,ii,sizeFilenames = Filenames.size();
+       int j,sizeFileEnd = bbGetInputFileEnd().size();
 
+       int okEraseElement;
+       
+//Selecting just the files in the FileEnd List
+       if (bbGetInputFileEnd().size()!=0)
+       {
+               for (i=sizeFilenames-1; i>=0; i--)
+               {
+                       okEraseElement=0;
+                       for (j=0; j<sizeFileEnd; j++)
+                       {
+                               std::string tmp=Filenames[i].substr( (Filenames[i].length()) - (bbGetInputFileEnd()[j]).length() ) ;
+                               if (bbGetInputFileEnd()[j].compare( tmp )==0 )
+                               {
+                                       okEraseElement++;
+                               } // if FileEnd
+                       } // for j                                      
+
+                       if (okEraseElement==0) 
+                       { 
+                               Filenames.erase( Filenames.begin()+i );
+                       }
+               } // for i      
+       } // if FileEnd !=0
+
+       sizeFilenames = Filenames.size();
 
 // Cleanning paths with spaces 
        for (i=0; i<sizeFilenames; i++)
        {
                tmpString=Filenames[i];
+
                std::string::size_type  spacePosition = tmpString.find_first_of(' ');
                if (spacePosition != std::string::npos)
                {
@@ -286,6 +313,7 @@ void FilesFromDirectory::CleanFilenames( std::string basePath )
                } // if spacePosition
        }
 
+
 // Alphabetical order  
        for (i=0; i<sizeFilenames; i++)
        {
@@ -304,7 +332,6 @@ void FilesFromDirectory::CleanFilenames( std::string basePath )
        unsigned int lenghtBasePath = basePath.length();
        for (i=0; i<sizeFilenames; i++)
        {
-
                SimpleFilenames.push_back( Filenames[i].substr( lenghtBasePath ) );
        } // for i
 
index 7d67556986c869538d1c584ec27d0978c9269345..852e83b529ac9c603daa477c6d5eb9e4d9c51b07 100644 (file)
@@ -42,6 +42,7 @@ namespace bbstd
     BBTK_DECLARE_INPUT(In,std::string);
     BBTK_DECLARE_INPUT(Recursive,bool);  
     BBTK_DECLARE_INPUT(Type,int);  
+    BBTK_DECLARE_INPUT(FileEnd,std::vector<std::string>);  
     BBTK_DECLARE_OUTPUT(Out,std::vector<std::string>);
     BBTK_DECLARE_OUTPUT(OutSimple,std::vector<std::string>);
     BBTK_PROCESS(Process);
@@ -70,6 +71,7 @@ namespace bbstd
    BBTK_INPUT(FilesFromDirectory,In,"Directory Name",std::string,"");
    BBTK_INPUT(FilesFromDirectory,Recursive,"Recursive directory exploration",bool,"");
    BBTK_INPUT(FilesFromDirectory,Type,"0=files 1=All_directories 2=last_directories  (0 default)",int,"");
+   BBTK_INPUT(FilesFromDirectory,FileEnd,"Select just the files with this end file name",std::vector<std::string>,"");
   
    BBTK_OUTPUT(FilesFromDirectory,Out,"FullPathNames of the files",std::vector<std::string>,"");
    BBTK_OUTPUT(FilesFromDirectory,OutSimple,"Simple Full PathNames of the files",std::vector<std::string>,"");