]> Creatis software - gdcm.git/commitdiff
ENH: Minor cleanup
authormalaterre <malaterre>
Wed, 27 Oct 2004 22:58:06 +0000 (22:58 +0000)
committermalaterre <malaterre>
Wed, 27 Oct 2004 22:58:06 +0000 (22:58 +0000)
src/gdcmDirList.cxx
src/gdcmDirList.h
src/gdcmUtil.cxx
src/gdcmUtil.h

index c04df60f64d1d895d7d37a790051d010d241f90b..394a0c4ed2e76016d1aed5431df8b0d8b30e0708 100644 (file)
@@ -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 <sys/stat.h>
    #include <sys/types.h>
 #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;
index 4e112d07b5931a8ca16f03d967f4df7e7dc568d7..47a55050fc199aed111fc58e515745fccc7d1b85 100644 (file)
@@ -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 <string>
 #include <list>
+
 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<std::string>
 {
 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;
 };
index ed2fe33f7578197ebf5c60a28dd7f6b018f06183..d09fe4534e49e0d7e4f9461928f00952e59d3d71 100644 (file)
@@ -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;
 }
 
 /**
index 2fb0ab22f192fad3adbc69cd4c9b903916dea2bc..6668b8035d38ec7d36fde1790a1791e5ecb4c696 100644 (file)
@@ -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);
 };