X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src2%2FcreaImageIOTreeHandlerImageAdder.cpp;h=f68fa778119294e18ab1043af820143868dbfae4;hb=d29be141890963fdc3236a28c81cd9dce0e19f69;hp=ef31c09f651f327a5276e9301c21c9e364063782;hpb=57608b6038aaf31b21948e6244aeb814f0bb7cbd;p=creaImageIO.git diff --git a/src2/creaImageIOTreeHandlerImageAdder.cpp b/src2/creaImageIOTreeHandlerImageAdder.cpp index ef31c09..f68fa77 100644 --- a/src2/creaImageIOTreeHandlerImageAdder.cpp +++ b/src2/creaImageIOTreeHandlerImageAdder.cpp @@ -1,11 +1,15 @@ #include #include -//#include -//#include - #include "boost/filesystem.hpp" +#include +#include + namespace fs = boost::filesystem; +using boost::filesystem::path; +using boost::next; +using boost::prior; + //using namespace crea; @@ -46,7 +50,7 @@ namespace creaImageIO std::vector::const_iterator i; for (i=filenames.begin();i!=filenames.end();++i) { - + mTimestampHandler->AddFile((*i), fs::last_write_time(*i), time(0)); mProgress.IncNumberScannedFiles(); if (IsHandledFile(*i)) { @@ -93,7 +97,8 @@ namespace creaImageIO mProgress.IncNumberScannedDirs(); if ( !fs::exists( dirpath ) ) return; - + time_t lastModif=fs::last_write_time(dirpath); + fs::directory_iterator end_itr; // default construction yields past-the-end for ( fs::directory_iterator itr( dirpath ); itr != end_itr; @@ -102,72 +107,37 @@ namespace creaImageIO // If is directory & recurse : do recurse if ( fs::is_directory(itr->status()) ) { - if (recursive) AddDirectoryRecursor( itr->string(), recursive); + if (recursive) + { + AddDirectoryRecursor( itr->string(), recursive); + } } else { - mProgress.IncNumberScannedFiles(); - if (IsHandledFile(itr->string())) - { - mProgress.IncNumberHandledFiles(); - AddFile( itr->string() ); - } - mProgressSignal(mProgress); - if (mProgress.GetStop()) break; + std::string parent_id; + bool valid=mTimestampHandler->AddDirectory(dirpath, itr->string(), lastModif, time(0)); + if(valid) + { + mProgress.IncNumberScannedFiles(); + if (IsHandledFile(itr->string())) + { + mProgress.IncNumberHandledFiles(); + AddFile( itr->string() ); + mTreeHandler->GetTopLevelNodeId("FullFileName",itr->string(),parent_id); + mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",itr->string()); + } + mProgressSignal(mProgress); + if (mProgress.GetStop()) + { + //itr = end_itr; + break; + } + } + mTimestampHandler->SetAttribute("TopLevelNodeId",parent_id,"PATH",dirpath); } } - + } - - /* - - std::string fileName; - std::string dirName = dirpath; - - wxDir dir( std2wx(dirpath) ); - - if ( !dir.IsOpened() ) - { - // deal with the error here - wxDir would already log an error message - // explaining the exact reason of the failure - return; - } - - wxString filename; - - bool cont = dir.GetFirst(&filename, wxEmptyString, - wxDIR_FILES | wxDIR_HIDDEN ); - while ( cont ) - { - mProgress.IncNumberScannedFiles(); - - wxFileName wxffn(dir.GetName(),filename); - std::string ffn = wx2std(wxffn.GetFullPath()); - if (IsHandledFile(ffn)) - { - mProgress.IncNumberHandledFiles(); - AddFile( ffn ); - } - mProgressSignal(mProgress); - cont = ( dir.GetNext(&filename) && (!mProgress.GetStop()) ); - } - - // Recurse into subdirs - if ( recursive ) - { - cont = dir.GetFirst(&filename, wxEmptyString, - wxDIR_DIRS | wxDIR_HIDDEN ); - while ( cont ) - { - wxFileName wxffn(dir.GetName(),filename); - std::string ffn = wx2std(wxffn.GetFullPath()); - AddDirectoryRecursor( ffn, recursive); - cont = dir.GetNext(&filename); - } - } - - */ - //=======================================================================