本文整理汇总了C++中Path::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ Path::IsValid方法的具体用法?C++ Path::IsValid怎么用?C++ Path::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::IsValid方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Path
Path Path::operator + (const Path & rhs)
{
if(!IsValid() && !rhs.IsValid())
{
// return this invalid path.
return *this;
}
if(IsValid() && !rhs.IsValid())
{
// return this valid path
return *this;
}
if(!IsValid() && rhs.IsValid())
{
// return the rhs valid path.
return rhs;
}
// both paths are valid...
std::string sTmpStr[2] =
{
#if defined(_WINDOWS)
m_sDrive + m_sPath,
rhs.m_sPath,
#else
m_sPath,
rhs.m_sPath
#endif
};
// make sure sTmpStr has a / on the end.
if(sTmpStr[0][sTmpStr[0].length() - 1] != PATH_SEPARATOR_CHAR)
{
sTmpStr[0] += PATH_SEPARATOR_CHAR;
}
// make sure rhs path has NOT got a / at the start.
if(sTmpStr[1][0] == PATH_SEPARATOR_CHAR)
{
sTmpStr[1] = sTmpStr[1].substr(1, sTmpStr[1].length() - 1);
}
// create a new path object with the two path strings appended together.
return Path(sTmpStr[0] + sTmpStr[1], false);
}
示例2: defined
bool Path::operator == (const Path & rhs)
{
if(!IsValid() && !rhs.IsValid())
{
// both paths are invalid!
return true;
}
if(IsValid() != rhs.IsValid())
{
// one of the paths is valid, whilst the other is not!
return false;
}
std::string sTmpStr[2] =
{
#if defined(WIN32)
m_sDrive + m_sPath,
rhs.m_sDrive + rhs.m_sPath
#else
m_sPath,
rhs.m_sPath
#endif
};
// make sure both paths have a / on the end.
if(sTmpStr[0][sTmpStr[0].length() - 1] != PATH_SEPARATOR_CHAR)
{
sTmpStr[0] += PATH_SEPARATOR_CHAR;
}
if(sTmpStr[1][sTmpStr[1].length() - 1] != PATH_SEPARATOR_CHAR)
{
sTmpStr[1] += PATH_SEPARATOR_CHAR;
}
return sTmpStr[0] == sTmpStr[1];
}