int main(int argc, char* argv[])
{
gengetopt_args_info args;
- if (cmdline_parser (argc, argv, &args) != 0) exit(1) ;
+ if (cmdline_parser (argc, argv, &args) != 0) return 0 ;
creaImageIO::Gimmick g;
if (args.verbose_given) g.SetMessageLevel(args.verbose_arg);
if (!something_to_do)
{
std::cout << "Nothing to do !" << std::endl;
- exit(0);
+ return 0;
}
std::string handler("Local database");
#include <creaImageIOTreeHandlerImageAdder.h>
-#include <creaWx.h>
-#include <wx/dir.h>
-#include <wx/filename.h>
+#include <creaImageIOSystem.h>
+//#include <wx/dir.h>
+//#include <wx/filename.h>
-using namespace crea;
+#include "boost/filesystem.hpp"
+
+namespace fs = boost::filesystem;
+
+//using namespace crea;
namespace creaImageIO
{
{
mProgress.Reset();
AddDirectoryRecursor( directory, recurse );
+ GimmickDebugMessage(3,mProgress<<std::endl);
}
//=====================================================================
//=====================================================================
void TreeHandlerImageAdder::AddFile( const std::string& filename )
{
-
+ GimmickDebugMessage(4,"Adding '"<<filename<<"'"<<std::endl);
std::map< std::string, std::string> attr;
mTreeHandler->GetTree().GetDescriptor().BuildAttributeMap(attr);
void TreeHandlerImageAdder::AddDirectoryRecursor(const std::string &dirpath,
bool recursive)
{
+ GimmickDebugMessage(4,"Scanning '"<<dirpath<<"'"<<std::endl);
mProgress.IncNumberScannedDirs();
+ if ( !fs::exists( dirpath ) ) return;
+
+ fs::directory_iterator end_itr; // default construction yields past-the-end
+ for ( fs::directory_iterator itr( dirpath );
+ itr != end_itr;
+ ++itr )
+ {
+ // If is directory & recurse : do recurse
+ if ( fs::is_directory(itr->status()) )
+ {
+ 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 fileName;
std::string dirName = dirpath;
cont = dir.GetNext(&filename);
}
}
-
- }
+
+ */
+
//=======================================================================
//=======================================================================
+
+
+
} // EO namespace creaImageIO
+#include <iostream>
+inline std::ostream& operator << ( std::ostream& o,
+ const creaImageIO::TreeHandlerImageAdder::Progress& p)
+{
+ o << p.GetNumberScannedFiles() << " files - "
+ << p.GetNumberScannedDirs() << " dirs - "
+ << p.GetNumberHandledFiles() << " handled -"
+ << p.GetNumberAddedFiles() << " added";
+ return o;
+}
+
// EOF
#endif
{
SetName ( name );
}
-
+ GimmickDebugMessage(5,"Constructing vtkImageReader : "<<GetName()
+ <<std::endl);
}
//=====================================================================
//=====================================================================
VtkImageReader::~VtkImageReader()
{
+ GimmickDebugMessage(5,"Destructing vtkImageReader : "<<GetName()
+ <<std::endl);
mReader->Delete();
}
//=====================================================================