]> Creatis software - gdcm.git/commitdiff
* src/gdcmDirList.[h|cxx] : add method to find a directory
authorregrain <regrain>
Tue, 1 Feb 2005 09:46:14 +0000 (09:46 +0000)
committerregrain <regrain>
Tue, 1 Feb 2005 09:46:14 +0000 (09:46 +0000)
  * Test/TestAllReadCompareDicom.cxx : bug fix under Windows
   -- BeNours

ChangeLog
Testing/TestAllReadCompareDicom.cxx
src/gdcmDirList.cxx
src/gdcmDirList.h

index 237d1f0f1bf7ae74eb5ffec3976a2d57764152a8..eadc05b30f5b4d0baf592a19f4dbbbce90410641 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
+2005-01-31 Benoit Regrain <Benoit.Regrain@creatis.insa-lyon.fr>
+  * src/gdcmDirList.[h|cxx] : add method to find a directory
+  * Test/TestAllReadCompareDicom.cxx : bug fix under Windows
+
 2005-01-31 Mathieu Malaterre  <Mathieu.Malaterre@creatis.insa-lyon.fr>
   * Finish cleaning up my JPEG mess. Should be ok now.
-       * Getting toward a RLE very similar to JPEG. Every RLE stuff is now self
+  * Getting toward a RLE very similar to JPEG. Every RLE stuff is now self
        contained within the RLE* class(doh!)
 
 2005-01-30 Jean-Pierre Roux <jpr@creatis.univ-lyon1.fr>
index 0194a97c1314310c259511a50242df061efd1654..a4bffdea563de79836891017f946125be95e2f79 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: TestAllReadCompareDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/31 03:36:59 $
-  Version:   $Revision: 1.26 $
+  Date:      $Date: 2005/02/01 09:46:15 $
+  Version:   $Revision: 1.27 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
      PURPOSE.  See the above copyright notices for more information.
                                                                                 
 =========================================================================*/
+#include "gdcmDirList.h"
 #include "gdcmFile.h"
 #include "gdcmFileHelper.h"
 
 #include <iostream>
 #include <fstream>
 
+#ifdef _MSC_VER
+   #include <windows.h>
+#endif
+
 //Generated file:
 #include "gdcmDataImages.h"
 
@@ -194,10 +199,9 @@ int TestAllReadCompareDicom(int argc, char* argv[])
       ////// Check for existence of reference baseline directory
 
       std::string baseLineDir = GDCM_DATA_ROOT;
-      baseLineDir += "/BaselineDicom/";
+      baseLineDir += "/BaselineDicom";
 
-      std::ifstream testDIR(baseLineDir.c_str(), std::ios::in | std::ios::binary);
-      if (!testDIR )
+      if( !gdcm::DirList::IsDirectory(baseLineDir) )
       {
          std::cerr << "   The reference baseline directory " << std::endl
                    << "      "
@@ -206,7 +210,9 @@ int TestAllReadCompareDicom(int argc, char* argv[])
                    << std::endl;
          return 1;
       }
-      testDIR.close();
+#ifndef _MSC_VER
+      testDir.close();
+#endif
 
       ////// Step 1 (see above description):
       std::string filename = GDCM_DATA_ROOT;
@@ -215,7 +221,7 @@ int TestAllReadCompareDicom(int argc, char* argv[])
       
       std::string referenceFileName = baseLineDir + gdcmDataImages[i++];
       std::string::size_type slash_pos = referenceFileName.rfind( "." );
-      if ( slash_pos != std::string::npos )
+      if( slash_pos != std::string::npos )
       {
          referenceFileName.replace( slash_pos + 1, 3, "dcm" );
       }
index 4422a0a8434590af61cde2e9517a52ce61e25a22..c605b7b3a137481f3943653a448593ff4b1ba1ba 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDirList.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/01/18 08:01:41 $
-  Version:   $Revision: 1.39 $
+  Date:      $Date: 2005/02/01 09:46:15 $
+  Version:   $Revision: 1.40 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -149,6 +149,17 @@ int DirList::Explore(std::string const &dirpath, bool recursive)
 
   return numberOfFiles;
 }
+
+bool DirList::IsDirectory(std::string const &dirName)
+{
+#ifndef _MSC_VER
+   std::ifstream testDir(dirName.c_str(), std::ios::in | std::ios::binary);
+   return testDir != 0;
+#else
+   return (GetFileAttributes(dirName.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
+#endif
+}
+
 } // end namespace gdcm
 
 //-----------------------------------------------------------------------------
index 171a1a6972ccf0ac011ce88fc891d845b9719d7e..6e8ae620a29cb12369b362644a74aa86a75237a4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDirList.h,v $
   Language:  C++
-  Date:      $Date: 2005/01/28 17:01:30 $
-  Version:   $Revision: 1.20 $
+  Date:      $Date: 2005/02/01 09:46:15 $
+  Version:   $Revision: 1.21 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -55,6 +55,8 @@ public :
    /// Print all element of the DirList
    void Print(std::ostream &os = std::cout);
 
+   static bool IsDirectory(std::string const &dirName);
+
 private :
    int Explore(std::string const &dirName, bool recursive=false);