Exemple #1
0
	Path Path::getParent()
	{
		if(m_sPath.length() == 0 || IsRoot())
		{
			// return empty path.
			return Path("");
		}
		
		// reverse find a / ignoring the end / if it exists.
		std::string::size_type nLength(m_sPath.length());
		std::string::size_type nOffset ((m_sPath[nLength - 1] == PATH_SEPARATOR_CHAR && nLength - 2 > 0) ? nLength - 2 : std::string::npos);
		std::string::size_type nPos (m_sPath.rfind(PATH_SEPARATOR_STR, nOffset));
		
		// create new path object given position of find / and return it.
		if(nPos != std::string::npos)
		{
	#if defined(_WINDOWS)
			return Path(m_sDrive + m_sPath.substr(0, nPos + 1), false);
	#else
			return Path(m_sPath.substr(0, nPos + 1), false);
	#endif
		}
		else
		{
			// not parent path avaliable, return an empty path.
			return Path("");
		}    
	}
Exemple #2
0
size_t	GetReportPath(VDinfoP VDptr, char* szDestPath, size_t nLength)
{
	size_t nPos(0);

	if ( totalDomains>0 && VDptr ) 
	{
		nPos += PathFromFullPath( MyPrefStruct.outfile, szDestPath);	// not safe - oh well.
		nPos += mystrncpy(szDestPath+nPos, GetDomainPath(VDptr), (nLength-nPos));
		nPos += mystrncpy(szDestPath+nPos, PATHSEPSTR,			 (nLength-nPos));
		if (nPos >= nLength)	// if there is no space left in the string.
			return nPos;
		ReplacePathFromHost( GetDomainPath(VDptr), szDestPath );
	}
	else
	{
		nPos += PathFromFullPath( MyPrefStruct.outfile, szDestPath);
	}

	return nPos;
}
Exemple #3
0
	std::string Path::GetBaseFileName()
	{
		if(m_sPath.length() == 0)
		{
			// return empty name.
			return "";
		}
		
		// reverse find a / ignoring the end / if it exists.
		std::string::size_type nLength(m_sPath.length());
		std::string::size_type nOffset((m_sPath[nLength - 1] == PATH_SEPARATOR_CHAR && nLength - 2 > 0) ? nLength - 2 : std::string::npos);
		std::string::size_type nPos (m_sPath.rfind(PATH_SEPARATOR_STR, nOffset));
		
		// extract filename given position of find / and return it.
		if(nPos != std::string::npos)
		{
			return m_sPath.substr(nPos + 1, nLength - (nPos + 1) - (nOffset != std::string::npos ? 1 : 0));
		}
		else
		{
			return m_sPath;
		} 
	}