Program: gdcm
Module: $RCSfile: gdcmDirList.cxx,v $
Language: C++
- Date: $Date: 2005/01/18 08:01:41 $
- Version: $Revision: 1.39 $
+ Date: $Date: 2005/02/02 15:07:41 $
+ Version: $Revision: 1.43 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace gdcm
{
+//-----------------------------------------------------------------------------
// Constructor / Destructor
/**
* \brief Constructor
//-----------------------------------------------------------------------------
// Public
-
-/**
- * \brief Print method
- * @param os ostream to write to
- */
-void DirList::Print(std::ostream &os)
+bool DirList::IsDirectory(std::string const &dirName)
{
- std::copy(Filenames.begin(), Filenames.end(),
- std::ostream_iterator<std::string>(os, "\n"));
+#ifndef _MSC_VER
+ struct stat buf;
+ stat(dirName.c_str(), &buf);
+ return S_ISDIR(buf.st_mode);
+#else
+ return (GetFileAttributes(dirName.c_str()) & FILE_ATTRIBUTE_DIRECTORY) != 0;
+#endif
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Private
-
/**
* \brief Explore a directory with possibility of recursion
* return number of files read
return numberOfFiles;
}
-} // end namespace gdcm
//-----------------------------------------------------------------------------
+// Print
+/**
+ * \brief Print method
+ * @param os ostream to write to
+ */
+void DirList::Print(std::ostream &os)
+{
+ std::copy(Filenames.begin(), Filenames.end(),
+ std::ostream_iterator<std::string>(os, "\n"));
+}
+
+//-----------------------------------------------------------------------------
+} // end namespace gdcm