Esempio n. 1
0
//==================================================================
AnsiStr ExtractOneLevelUp(const AnsiStr& strFilePath)
{
	AnsiStr strOutput = strFilePath;
	bool bHasLastSlash = false;
	char lastSlash;

	//Remove last forward or backward slash
	while((strOutput.lastChar() == '/') || (strOutput.lastChar() == '\\'))
	{
		lastSlash = strOutput.lastChar();
		strOutput = strOutput.substr(0, strOutput.length() - 1);		
		bHasLastSlash = true;
	}

    int pos = 0;
	//Up one level
	if(strOutput.rfind('/', pos))
		strOutput = strOutput.substr(0, pos);
	else if(strOutput.rfind('\\', pos))
		strOutput = strOutput.substr(0, pos);
	
	if(bHasLastSlash)
		strOutput += lastSlash;

	return strOutput;
}
Esempio n. 2
0
//==================================================================
AnsiStr ExtractFilePath(const AnsiStr& fileName)
{
    int npos;
	AnsiStr strOutput;
	if(fileName.rfind(L'/', npos) || fileName.rfind(L'\\', npos))	
	{
		strOutput = fileName.substr(0, npos+1);
	}
	return strOutput;	
}
Esempio n. 3
0
//==================================================================
AnsiStr ExtractFileName(const AnsiStr& strPathFileName)
{
    int npos;

	AnsiStr strOutput = strPathFileName;
	if(strPathFileName.rfind(L'/', npos) || strPathFileName.rfind(L'\\', npos))
	{
		strOutput = strPathFileName.substr(npos+1);
	}

	return strOutput;
}
Esempio n. 4
0
//==================================================================
AnsiStr ExtractFileExt(const AnsiStr& strPathFileName)
{
    int npos;
	AnsiStr strOut;
	if(strPathFileName.rfind('.', npos))
	{
		strOut = strPathFileName.substr(npos+1);
	}
	return strOut;	
}
Esempio n. 5
0
//==================================================================
AnsiStr CreateNewFileAtRoot(const char* pExtWithDot)
{
    AnsiStr strOutput = ps::dir::GetExePath();
    int posDot;
	if(strOutput.rfind(L'.', posDot))
	{
		AnsiStr temp = strOutput.substr(0, posDot);
		temp.appendFromT(pExtWithDot);
		return temp;
	}
	else
		return strOutput;	
}
Esempio n. 6
0
//==================================================================
AnsiStr ChangeFileExt(const AnsiStr& strFilePath, const AnsiStr& strExtWithDot)
{
	AnsiStr strOut;
    int npos;
	if(strFilePath.rfind('.', npos))
	{
		strOut = strFilePath.substr(0, npos);
		strOut += strExtWithDot;
	}
	else
		strOut = strFilePath + strExtWithDot;

	return strOut;
}