From 104b91460e28364b160e2f9ad518be3758c477b2 Mon Sep 17 00:00:00 2001 From: malaterre Date: Fri, 14 Jan 2005 22:20:11 +0000 Subject: [PATCH] BUG: Could not use DirList from a dll on windows since the symbol was not exported. So I had to rewrite the class a little. the usage is slightly more complex now (one more function call) --- src/gdcmDicomDir.cxx | 12 +++++++----- src/gdcmDirList.cxx | 21 +++++++-------------- src/gdcmDirList.h | 26 ++++++++++++++------------ src/gdcmSerieHeader.cxx | 9 +++++---- 4 files changed, 33 insertions(+), 35 deletions(-) diff --git a/src/gdcmDicomDir.cxx b/src/gdcmDicomDir.cxx index cbaa1367..541273ab 100644 --- a/src/gdcmDicomDir.cxx +++ b/src/gdcmDicomDir.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDicomDir.cxx,v $ Language: C++ - Date: $Date: 2005/01/13 12:19:58 $ - Version: $Revision: 1.100 $ + Date: $Date: 2005/01/14 22:20:11 $ + Version: $Revision: 1.101 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -414,12 +414,14 @@ bool DicomDir::WriteDicomDir(std::string const &fileName) void DicomDir::CreateDicomDirChainedList(std::string const & path) { CallStartMethod(); - DirList fileList(path,1); // gets recursively the file list + DirList dirList(path,1); // gets recursively the file list unsigned int count = 0; VectDocument list; Header *header; - for( DirList::iterator it = fileList.begin(); + DirListType fileList = dirList.GetFilenames(); + + for( DirListType::iterator it = fileList.begin(); it != fileList.end(); ++it ) { @@ -452,7 +454,7 @@ void DicomDir::CreateDicomDirChainedList(std::string const & path) // sorts Patient/Study/Serie/ std::sort(list.begin(), list.end(), DicomDir::HeaderLessThan ); - std::string tmp = fileList.GetDirName(); + std::string tmp = dirList.GetDirName(); //for each Header of the chained list, add/update the Patient/Study/Serie/Image info SetElements(tmp, list); CallEndMethod(); diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 65c6b358..083dfa04 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/14 21:52:06 $ - Version: $Revision: 1.33 $ + Date: $Date: 2005/01/14 22:20:11 $ + Version: $Revision: 1.34 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -53,24 +53,17 @@ DirList::~DirList() { } -//----------------------------------------------------------------------------- -// Print - //----------------------------------------------------------------------------- // Public + /** * \ingroup DirList - * \brief Get the directory name - * @return the directory name + * \brief Print method */ -std::string const &DirList::GetDirName() const -{ - return DirName; -} - void DirList::Print(std::ostream &os) { - copy(begin(), end(), std::ostream_iterator(os, "\n")); + std::copy(Filenames.begin(), Filenames.end(), + std::ostream_iterator(os, "\n")); } //----------------------------------------------------------------------------- @@ -138,7 +131,7 @@ int DirList::Explore(std::string const &dirpath, bool recursive) stat(fileName.c_str(), &buf); //really discard output ? if( S_ISREG(buf.st_mode) ) //is it a regular file? { - push_back( fileName ); + Filenames.push_back( fileName ); numberOfFiles++; } else if( S_ISDIR(buf.st_mode) ) //directory? diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 8361a808..7e79044b 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/14 21:52:06 $ - Version: $Revision: 1.17 $ + Date: $Date: 2005/01/14 22:20:11 $ + Version: $Revision: 1.18 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -37,26 +37,28 @@ namespace gdcm // NOTE: Due to a VC6 'feature' we can not export a std::list in a dll, // so GDCM_EXPORT keyword was removed for this class only -class DirList : public std::vector +typedef std::vector DirListType; + +class GDCM_EXPORT DirList { public : DirList(std::string const &dirName, bool recursive=false); - virtual ~DirList(); + ~DirList(); - std::string const &GetDirName() const; + /// Return the name of the directory + std::string const &GetDirName() const { return DirName; } - void Print(std::ostream &os = std::cout); + /// Return the file names + DirListType const &GetFilenames() const { return Filenames; }; - /// Character '\' - static const char SEPARATOR_X; - /// Character '/' - static const char SEPARATOR_WIN; - /// depending on the O.S. - static const std::string SEPARATOR; + /// Print all element of the DirList + void Print(std::ostream &os = std::cout); private : int Explore(std::string const &dirName, bool recursive=false); + DirListType Filenames; + /// name of the root directory to explore std::string DirName; }; diff --git a/src/gdcmSerieHeader.cxx b/src/gdcmSerieHeader.cxx index 64fffb41..e1347e26 100644 --- a/src/gdcmSerieHeader.cxx +++ b/src/gdcmSerieHeader.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmSerieHeader.cxx,v $ Language: C++ - Date: $Date: 2005/01/14 21:34:53 $ - Version: $Revision: 1.8 $ + Date: $Date: 2005/01/14 22:20:11 $ + Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -97,9 +97,10 @@ void SerieHeader::AddFileName(std::string const &filename) void SerieHeader::SetDirectory(std::string const &dir) { CurrentSerieUID = ""; //Reset previous Serie Instance UID - DirList filenames_list(dir); //OS specific + DirList dirList(dir); //OS specific - for( DirList::const_iterator it = filenames_list.begin(); + DirListType filenames_list = dirList.GetFilenames(); + for( DirListType::const_iterator it = filenames_list.begin(); it != filenames_list.end(); ++it) { AddFileName( *it ); -- 2.48.1