]> Creatis software - bbtk.git/blobdiff - packages/std/src/bbstdFilesFromDirectory.cxx
#3385 BBTK Bug New Normal - box FilesFromDirectory CreateImage InvertCrop ComboBox...
[bbtk.git] / packages / std / src / bbstdFilesFromDirectory.cxx
index 3a694d2d48d8070c607089deeff434af2a53fdac..387b5ad77aacfd7a2043b9048daed5491c20cdec 100644 (file)
@@ -293,24 +293,27 @@ if (recursiveLevel>=0){
 void FilesFromDirectory::CleanFilenames( std::string basePath )
 {
        std::string tmpString;
-       int i,ii,sizeFilenames = Filenames.size();
-       int j,sizeFileEnd = bbGetInputFileEnd().size();
-
+       int i,ii,sizeFilenames  = Filenames.size();
+       int j,sizeFileEnd               = bbGetInputFileEnd().size();
        int okEraseElement;
-       
+       int posStr;
 //Selecting just the files in the FileEnd List
        if (bbGetInputFileEnd().size()!=0)
        {
                for (i=sizeFilenames-1; i>=0; i--)
                {
-                       okEraseElement=0;
+                       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 )
+                               posStr=(Filenames[i].length()) - (bbGetInputFileEnd()[j]).length();
+                               if (posStr>=0)
                                {
-                                       okEraseElement++;
-                               } // if FileEnd
+                                       std::string tmp=Filenames[i].substr( posStr ) ;
+                                       if (bbGetInputFileEnd()[j].compare( tmp )==0 )
+                                       {
+                                               okEraseElement++;
+                                       } // if FileEnd
+                               }// if posStr
                        } // for j                                      
 
                        if (okEraseElement==0) 
@@ -319,14 +322,11 @@ void FilesFromDirectory::CleanFilenames( std::string basePath )
                        }
                } // 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)
                {
@@ -338,7 +338,6 @@ void FilesFromDirectory::CleanFilenames( std::string basePath )
                } // if spacePosition
        }
 
-
 // Alphabetical order  
        for (i=0; i<sizeFilenames; i++)
        {
@@ -352,14 +351,12 @@ void FilesFromDirectory::CleanFilenames( std::string basePath )
                } // if 
        } // for ii
        } // for i
-
 // Creating SimpleFilenames
        unsigned int lenghtBasePath = basePath.length();
        for (i=0; i<sizeFilenames; i++)
        {
                SimpleFilenames.push_back( Filenames[i].substr( lenghtBasePath ) );
        } // for i
-
 }