]> Creatis software - creaBruker.git/blobdiff - lib/src1/bruker2dicom.cxx
Try double check
[creaBruker.git] / lib / src1 / bruker2dicom.cxx
index 30407ea919902918056cb020f1d48715a5a53506..737131192fa455e3b24bcd6484f30d1331931bd0 100644 (file)
@@ -1,4 +1,6 @@
 #include "bruker2dicom.h"
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
 
 #ifndef PATH_MAX // If not defined yet : do it 
        #define PATH_MAX 2048
@@ -12,7 +14,8 @@ bool Bruker2Dicom::Execute()
 
    bool bigEndian = GDCM_NAME_SPACE::Util::IsCurrentProcessorBigEndian();
  
-   if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(InputDirName) )
+   //if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(InputDirName) )
+   if ( ! boost::filesystem::is_directory(InputDirName) )
    {
       std::cout << "KO : [" << InputDirName << "] is not a Directory." << std::endl;
       return 0;
@@ -125,7 +128,8 @@ bool Bruker2Dicom::Execute()
          it != fileNames.end();
        ++it)
    {
-      if ( GDCM_NAME_SPACE::DirList::IsDirectory(*it) )
+      if ( !boost::filesystem::is_regular(*it) ) // check twice !
+      if ( boost::filesystem::is_directory(*it) )
       { 
          if (verbose)
             std::cout << "[" << *it << "] is a directory" << std::endl;
@@ -219,7 +223,8 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr
         it != fileNames.end();
       ++it)
    {
-      if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(*it) )
+      if ( boost::filesystem::is_regular(*it) ) 
+      //if ( ! boost::filesystem::is_directory(*it) )
       {
          if (verbose)
             std::cout << "--- [" << *it << "] is a file" << std::endl;
@@ -233,7 +238,8 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr
         it != fileNames.end();
       ++it)
    {
-      if ( GDCM_NAME_SPACE::DirList::IsDirectory(*it) )
+      if ( !boost::filesystem::is_regular(*it) ) // check twice !  
+      if ( boost::filesystem::is_directory(*it) )
       {
          // will be always "pdata" ...
          if (verbose)
@@ -329,7 +335,8 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr
         it != fileNames.end();
       ++it)
    {
-      if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(*it) )
+      if ( !boost::filesystem::is_regular(*it) ) 
+      //if ( ! boost::filesystem::is_directory(*it) )
       { 
          std::cout << "--- --- [" << *it << "] is a file" << std::endl;
       }
@@ -340,7 +347,8 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr
          it != fileNames.end();
        ++it)
    {
-      if ( GDCM_NAME_SPACE::DirList::IsDirectory(*it) )
+      if ( !boost::filesystem::is_regular(*it) ) // check twice !
+      if ( boost::filesystem::is_directory(*it) )
       { 
   
          if (verbose)
@@ -813,7 +821,8 @@ void Bruker2Dicom::dealWithCarto(GDCM_NAME_SPACE::DirListType &fileNames, int NX
         it != fileNames.end();
       ++it)
    {
-      if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(*it) )
+      if ( boost::filesystem::is_regular(*it) )
+      //if ( ! boost::filesystem::is_directory(*it) )
       {         
          if (verbose)
             std::cout << "--- [" << *it << "] is a file" << std::endl;
@@ -931,15 +940,15 @@ bool Bruker2Dicom::CreateDirectory(std::string OutputDirName)
    
    if (verbose)
       std::cout << "Check for output directory :[" << OutputDirName << "]."
-                <<std::endl;
-   if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(OutputDirName) )    // dirout not found
+                <<std::endl;           
+   if ( ! boost::filesystem::is_directory(OutputDirName) )    // dirout not found
    {
       std::string strDirNameout(OutputDirName);        // to please gcc 4
       systemCommand = "mkdir " + strDirNameout;        // create it!
       if (verbose)
          std::cout << systemCommand << std::endl;
       system (systemCommand.c_str());
-      if ( ! GDCM_NAME_SPACE::DirList::IsDirectory(OutputDirName) ) // be sure it worked
+      if ( ! boost::filesystem::is_directory(OutputDirName) ) // be sure it worked
       {
          if (verbose) 
             std::cout << "KO : not a dir : [" << OutputDirName << "] (creation failure ?)" << std::endl;