From 6bcd9b8c2dca341ac79674be22c3d09323ee6e78 Mon Sep 17 00:00:00 2001 From: malaterre Date: Wed, 27 Oct 2004 22:58:06 +0000 Subject: [PATCH] ENH: Minor cleanup --- src/gdcmDirList.cxx | 14 +++++++------- src/gdcmDirList.h | 13 ++++++++----- src/gdcmUtil.cxx | 8 +++++--- src/gdcmUtil.h | 6 +++--- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index c04df60f..394a0c4e 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.cxx,v $ Language: C++ - Date: $Date: 2004/10/12 04:35:45 $ - Version: $Revision: 1.23 $ + Date: $Date: 2004/10/27 22:58:06 $ + Version: $Revision: 1.24 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -33,9 +33,9 @@ #include #include #endif + namespace gdcm { - // Constructor / Destructor /** * \ingroup DirList @@ -43,7 +43,7 @@ namespace gdcm * @param dirName root directory name * @param recursive whether we want to explore recursively or not */ -DirList::DirList(std::string dirName, bool recursive) +DirList::DirList(std::string const & dirName, bool recursive) { name = dirName; Util::NormalizePath(name); @@ -68,7 +68,7 @@ DirList::~DirList() * \brief Get the directory name * @return the directory name */ -std::string DirList::GetDirName() +std::string const & DirList::GetDirName() const { return name; } @@ -86,12 +86,12 @@ std::string DirList::GetDirName() * @param dirName directory to explore * @param recursive whether we want recursion or not */ -int DirList::Explore(std::string dirName, bool recursive) +int DirList::Explore(std::string const & dirName, bool recursive) { int numberOfFiles = 0; std::string fileName; Util::NormalizePath(dirName); -#if defined(_MSC_VER) || (__CYGWIN__) +#if defined(_MSC_VER) || defined(__CYGWIN__) WIN32_FIND_DATA fileData; HANDLE hFile=FindFirstFile((dirName+"*").c_str(),&fileData); int found = true; diff --git a/src/gdcmDirList.h b/src/gdcmDirList.h index 4e112d07..47a55050 100644 --- a/src/gdcmDirList.h +++ b/src/gdcmDirList.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmDirList.h,v $ Language: C++ - Date: $Date: 2004/10/16 14:34:12 $ - Version: $Revision: 1.12 $ + Date: $Date: 2004/10/27 22:58:06 $ + Version: $Revision: 1.13 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,6 +23,7 @@ #include #include + namespace gdcm { @@ -33,13 +34,14 @@ 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::list { public : - DirList(std::string dirName,bool recursive=false); + DirList(std::string const & dirName, bool recursive=false); virtual ~DirList(); - std::string GetDirName(); + std::string const & GetDirName() const; /// Character '\' static const char SEPARATOR_X; @@ -49,7 +51,8 @@ public : static const std::string SEPARATOR; private : - int Explore(std::string dirName,bool recursive=false); + int Explore(std::string const & dirName, bool recursive=false); + /// name of the root directory to explore std::string name; }; diff --git a/src/gdcmUtil.cxx b/src/gdcmUtil.cxx index ed2fe33f..d09fe453 100644 --- a/src/gdcmUtil.cxx +++ b/src/gdcmUtil.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.cxx,v $ Language: C++ - Date: $Date: 2004/10/25 04:47:43 $ - Version: $Revision: 1.55 $ + Date: $Date: 2004/10/27 22:58:06 $ + Version: $Revision: 1.56 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -130,17 +130,19 @@ std::string Util::CreateCleanString(std::string const & s) * \brief Add a SEPARATOR to the end of the name is necessary * @param name file/directory name to normalize */ -void Util::NormalizePath(std::string &name) +std::string Util::NormalizePath(std::string const & pathname) { const char SEPARATOR_X = '/'; const char SEPARATOR_WIN = '\\'; const std::string SEPARATOR = "/"; + std::string name = pathname; int size = name.size(); if( name[size-1] != SEPARATOR_X && name[size-1] != SEPARATOR_WIN ) { name += SEPARATOR; } + return name; } /** diff --git a/src/gdcmUtil.h b/src/gdcmUtil.h index 2fb0ab22..6668b803 100644 --- a/src/gdcmUtil.h +++ b/src/gdcmUtil.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmUtil.h,v $ Language: C++ - Date: $Date: 2004/10/25 04:47:43 $ - Version: $Revision: 1.37 $ + Date: $Date: 2004/10/27 22:58:06 $ + Version: $Revision: 1.38 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -45,7 +45,7 @@ public: const std::string& subStr); static std::string CreateCleanString(std::string const & s); - static void NormalizePath(std::string &name); + static std::string NormalizePath(std::string const & name); static std::string GetPath(std::string const &fullName); static std::string GetName(std::string const &fullName); }; -- 2.45.1