Line 435:-
Code: Select all
if ( texnameWithUserPath.size() )
{
texname = FileSystem->getFileBasename( texname ); // Strip MTL preset path if exists from name. Robmar mode
texnameWithUserPath += texname;
}
Code: Select all
//! returns the base part of a filename, i.e. all except for the directory
//! part. If no directory path is prefixed, the full name is returned.
io::path CFileSystem::getFileBasename(const io::path& filename, bool keepExtension) const
{
if (keepExtension)
{
u32 size = filename.size(); // Robmar mod
int i;
for ( i = (int)size-1; i >= 0 && filename[i] != '/' && filename[i] != '\\'; i-- ) ; // Find last slash
if ( i >= 0 )
{
return filename.subString( i+1, size - (i+1) );
}
else
return filename;
}
else
{
// find last forward or backslash
s32 lastSlash = filename.findLast('/');
const s32 lastBackSlash = filename.findLast('\\');
lastSlash = core::max_(lastSlash, lastBackSlash);
// get number of chars after last dot
s32 end = 0;
if (!keepExtension)
{
// take care to search only after last slash to check only for
// dots in the filename
end = filename.findLast('.');
if (end == -1 || end < lastSlash)
end=0;
else
end = filename.size()-end;
}
if ((u32)lastSlash < filename.size())
return filename.subString(lastSlash+1, filename.size()-lastSlash-1-end);
else if (end != 0)
return filename.subString(0, filename.size()-end);
else
return filename;
}
}