From ebc807df21ba9e4e7ecae409d875ed46b47cd79c Mon Sep 17 00:00:00 2001 From: regrain Date: Tue, 1 Feb 2005 09:46:14 +0000 Subject: [PATCH] * src/gdcmDirList.[h|cxx] : add method to find a directory * Test/TestAllReadCompareDicom.cxx : bug fix under Windows -- BeNours --- ChangeLog | 6 +++++- Testing/TestAllReadCompareDicom.cxx | 20 +++++++++++++------- src/gdcmDirList.cxx | 15 +++++++++++++-- src/gdcmDirList.h | 6 ++++-- 4 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 237d1f0f..eadc05b3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ +2005-01-31 Benoit Regrain + * src/gdcmDirList.[h|cxx] : add method to find a directory + * Test/TestAllReadCompareDicom.cxx : bug fix under Windows + 2005-01-31 Mathieu Malaterre * 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 diff --git a/Testing/TestAllReadCompareDicom.cxx b/Testing/TestAllReadCompareDicom.cxx index 0194a97c..a4bffdea 100644 --- a/Testing/TestAllReadCompareDicom.cxx +++ b/Testing/TestAllReadCompareDicom.cxx @@ -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 @@ -15,12 +15,17 @@ PURPOSE. See the above copyright notices for more information. =========================================================================*/ +#include "gdcmDirList.h" #include "gdcmFile.h" #include "gdcmFileHelper.h" #include #include +#ifdef _MSC_VER + #include +#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" ); } diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 4422a0a8..c605b7b3 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -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 //----------------------------------------------------------------------------- diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 171a1a69..6e8ae620 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -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); -- 2.45.1