]> Creatis software - gdcm.git/commitdiff
Add
authorjpr <jpr>
Tue, 10 Jan 2006 15:54:03 +0000 (15:54 +0000)
committerjpr <jpr>
Tue, 10 Jan 2006 15:54:03 +0000 (15:54 +0000)
GDCM_EXPORT extern const char GDCM_FILESEPARATOR
to allow user to manage file names/directory names without using too much
#ifdef WIN32

src/gdcmCommon.h
src/gdcmDirList.cxx
src/gdcmUtil.cxx

index fa971dc53ff81913421cd43c0c13bde71770fefa..416cc3c4caf2b535de3c0134177a628327f68988 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmCommon.h,v $
   Language:  C++
-  Date:      $Date: 2005/10/23 15:32:30 $
-  Version:   $Revision: 1.101 $
+  Date:      $Date: 2006/01/10 15:54:03 $
+  Version:   $Revision: 1.102 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -62,6 +62,8 @@ GDCM_EXPORT extern const std::string GDCM_PIXELDATA;
 
 GDCM_EXPORT extern const std::string GDCM_VRUNKNOWN;
 
+GDCM_EXPORT extern const char GDCM_FILESEPARATOR;
+
 /// \brief TagKey is made to hold the standard Dicom Tag 
 ///               (Group number, Element number)
 /// Instead of using the two '16 bits integers' as the Hask Table key, we
index c0a9feda473503536eadf2ae8fc2bde204dae925..e6c0523913c1334044bf7642b851d055611517b4 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmDirList.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/12/13 13:37:50 $
-  Version:   $Revision: 1.57 $
+  Date:      $Date: 2006/01/10 15:54:03 $
+  Version:   $Revision: 1.58 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -65,7 +65,9 @@ DirList::~DirList()
 bool DirList::IsDirectory(std::string const &dirName)
 {
    struct stat fs;
-   assert( dirName[dirName.size()-1] != '/' );
+   // std::cout << "dirName[dirName.size()-1] [" << dirName[dirName.size()-1] << "]"
+   //           << std::endl;
+   //assert( dirName[dirName.size()-1] != GDCM_FILESEPARATOR );
    if ( stat(dirName.c_str(), &fs) == 0 )
    {
 #if _WIN32
@@ -100,7 +102,7 @@ int DirList::Explore(std::string const &dirpath, bool recursive)
    std::string dirName = Util::NormalizePath(dirpath);
 #ifdef _MSC_VER
    WIN32_FIND_DATA fileData;
-   assert( dirName[dirName.size()-1] == '/' );
+   //assert( dirName[dirName.size()-1] == '' );
    HANDLE hFile = FindFirstFile((dirName+"*").c_str(), &fileData);
 
    for(BOOL b = (hFile != INVALID_HANDLE_VALUE); b;
index 30d1ec45d2b77ea237252e12f5ff65501dfb790b..19895c1f4e960b4b09ff98135f55a897a9d7d5a3 100644 (file)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: gdcmUtil.cxx,v $
   Language:  C++
-  Date:      $Date: 2005/12/22 14:46:36 $
-  Version:   $Revision: 1.181 $
+  Date:      $Date: 2006/01/10 15:54:03 $
+  Version:   $Revision: 1.182 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -194,7 +194,6 @@ int Util::CountSubstring (const std::string &str,
  */
 bool Util::IsCleanString(std::string const &s)
 {
-   //std::cout<< std::endl << s << std::endl;
    for(unsigned int i=0; i<s.size(); i++)
    {
       if (!isprint((unsigned char)s[i]) )
@@ -279,20 +278,26 @@ std::string Util::CreateCleanString(uint8_t *s, int l)
 }
 /**
  * \brief   Add a SEPARATOR to the end of the name if necessary
- * \todo ask the writer of this method *why* he always add a /
  * @param   pathname file/directory name to normalize 
  */
 std::string Util::NormalizePath(std::string const &pathname)
 {
+/*
    const char SEPARATOR_X      = '/';
    const char SEPARATOR_WIN    = '\\';
+#ifdef _WIN32
+   const std::string SEPARATOR = "\\";
+#else
    const std::string SEPARATOR = "/";
+#endif
+*/
    std::string name = pathname;
    int size = name.size();
 
-   if ( name[size-1] != SEPARATOR_X && name[size-1] != SEPARATOR_WIN )
+//   if ( name[size-1] != SEPARATOR_X && name[size-1] != SEPARATOR_WIN )
+   if ( name[size-1] != GDCM_FILESEPARATOR )
    {
-      name += SEPARATOR;
+      name += GDCM_FILESEPARATOR;
    }
    return name;
 }
@@ -304,6 +309,8 @@ std::string Util::NormalizePath(std::string const &pathname)
 std::string Util::GetPath(std::string const &fullName)
 {
    std::string res = fullName;
+/*
+   
    int pos1 = res.rfind("/");
    int pos2 = res.rfind("\\");
    if ( pos1 > pos2 )
@@ -314,7 +321,9 @@ std::string Util::GetPath(std::string const &fullName)
    {
       res.resize(pos2);
    }
-
+*/
+   int pos = res.rfind(GDCM_FILESEPARATOR);
+   res.resize(pos);
    return res;
 }
 
@@ -325,12 +334,14 @@ std::string Util::GetPath(std::string const &fullName)
 std::string Util::GetName(std::string const &fullName)
 {   
   std::string filename = fullName;
-
+/*
   std::string::size_type slash_pos = filename.rfind("/");
   std::string::size_type backslash_pos = filename.rfind("\\");
   // At least with my gcc4.0.1, unfound char results in pos =4294967295 ...
-  //slash_pos = slash_pos > backslash_pos ? slash_pos : backslash_pos;
+  //slash_pos = slash_pos > backslash_pos ? slash_pos : backslash_pos;  
   slash_pos = slash_pos < backslash_pos ? slash_pos : backslash_pos;
+*/
+  std::string::size_type slash_pos = filename.rfind(GDCM_FILESEPARATOR);
   if (slash_pos != std::string::npos )
     {
     return filename.substr(slash_pos + 1);