X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=src%2FgdcmDirList.cxx;h=e30f633728778482278b0bd9a99bff737d5fdd9c;hb=45a9005ae5c1975bbe932e43c8080a83c9daf29e;hp=42b3120a05198abac945de184934a7cb1c7290f3;hpb=e785350bf905bcac85e241f9cf9f07d03eae345d;p=gdcm.git diff --git a/src/gdcmDirList.cxx b/src/gdcmDirList.cxx index 42b3120a..e30f6337 100644 --- a/src/gdcmDirList.cxx +++ b/src/gdcmDirList.cxx @@ -1,46 +1,52 @@ -// gdcmDirList.cxx -//----------------------------------------------------------------------------- +/*========================================================================= + + Program: gdcm + Module: $RCSfile: gdcmDirList.cxx,v $ + Language: C++ + Date: $Date: 2004/06/20 18:08:47 $ + Version: $Revision: 1.16 $ + + Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de + l'Image). All rights reserved. See Doc/License.txt or + http://www.creatis.insa-lyon.fr/Public/Gdcm/License.htm for details. + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the above copyright notices for more information. + +=========================================================================*/ + #include "gdcmDirList.h" +#include "gdcmUtil.h" #include #include -#ifdef GDCM_NO_ANSI_STRING_STREAM - #include - #define ostringstream ostrstream -#else - #include -#endif - -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined (__CYGWIN__) #include +#ifdef _MSC_VER #include +#endif //_MSC_VER #else #include #include #endif -//----------------------------------------------------------------------------- -const char gdcmDirList::SEPARATOR_X = '/'; -const char gdcmDirList::SEPARATOR_WIN = '\\'; -const std::string gdcmDirList::SEPARATOR = "/"; - -//----------------------------------------------------------------------------- // Constructor / Destructor -/* +/** * \ingroup gdcmDirList * \brief Constructor - * @param + * @param dirName root directory name + * @param recursive whether we want to explore recursively or not */ gdcmDirList::gdcmDirList(std::string dirName,bool recursive) { name=dirName; - NormalizePath(name); Explore(name,recursive); } -/* +/** * \ingroup gdcmDirList * \brief Destructor */ @@ -53,10 +59,10 @@ gdcmDirList::~gdcmDirList(void) //----------------------------------------------------------------------------- // Public -/* +/** * \ingroup gdcmDirList * \brief Get the directory name - * @param + * @return the directory name */ std::string gdcmDirList::GetDirName(void) { @@ -68,32 +74,19 @@ std::string gdcmDirList::GetDirName(void) //----------------------------------------------------------------------------- // Private -/* - * \ingroup gdcmDirList - * \brief Add a SEPARATOR to the end of the directory name is necessary - * @param - */ -void gdcmDirList::NormalizePath(std::string &dirName) -{ - int size=dirName.size(); - if((dirName[size-1]!=SEPARATOR_X)&&(dirName[size-1]!=SEPARATOR_WIN)) - { - dirName+=SEPARATOR; - } -} -/* +/** * \ingroup gdcmDirList * \brief Explore a directory with possibility of recursion - * @param + * @param dirName directory to explore + * @param recursive whether we want recursion or not */ void gdcmDirList::Explore(std::string dirName,bool recursive) { std::string fileName; NormalizePath(dirName); - -#ifdef _MSC_VER +#if defined(_MSC_VER) || (__CYGWIN__) WIN32_FIND_DATA fileData; HANDLE hFile=FindFirstFile((dirName+"*").c_str(),&fileData); int found=true; @@ -101,7 +94,6 @@ void gdcmDirList::Explore(std::string dirName,bool recursive) while( (hFile!=INVALID_HANDLE_VALUE) && (found) ) { fileName=fileData.cFileName; - std::cout<d_name; + fileName=namelist[i]->d_name; if(namelist[i]->d_type==DT_DIR) { if( (fileName!=".") && (fileName!="..") && (recursive) )