Program: gdcm
Module: $RCSfile: gdcmUtil.cxx,v $
Language: C++
- Date: $Date: 2005/11/29 13:02:46 $
- Version: $Revision: 1.179 $
+ 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
*/
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]) )
return str;
}
/**
- * \brief Add a SEPARATOR to the end of the name is necessary
+ * \brief Add a SEPARATOR to the end of the name if necessary
* @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;
}
std::string Util::GetPath(std::string const &fullName)
{
std::string res = fullName;
+/*
+
int pos1 = res.rfind("/");
int pos2 = res.rfind("\\");
if ( pos1 > pos2 )
{
res.resize(pos2);
}
-
+*/
+ int pos = res.rfind(GDCM_FILESEPARATOR);
+ res.resize(pos);
return res;
}
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("\\");
- slash_pos = slash_pos > backslash_pos ? slash_pos : backslash_pos;
+ // 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;
+*/
+ std::string::size_type slash_pos = filename.rfind(GDCM_FILESEPARATOR);
if (slash_pos != std::string::npos )
{
return filename.substr(slash_pos + 1);
/**
* \brief Safely check the equality of two Dicom String:
* - Both strings should be of even length
- * - We allow padding of even length string by either a null
- * character of a space
+ * - We allow padding of even length string by either
+ * a null character of a space
*/
bool Util::DicomStringEqual(const std::string &s1, const char *s2)
{
/**
* \brief Safely compare two Dicom String:
* - Both strings should be of even length
- * - We allow padding of even length string by either a null
- * character of a space
+ * - We allow padding of even length string by either
+ * a null character of a space
*/
bool Util::CompareDicomString(const std::string &s1, const char *s2, int op)
{