getFileNameWithoutExtension identical works


#1

Hi.
Sorry, for insignificant question.
It’s question like “What was first - egg or hen?” but

const String File::getFileNameWithoutExtension() const throw()
{
    const int lastSlash = fullPath.lastIndexOfChar (separator) + 1;
    const int lastDot = fullPath.lastIndexOfChar (T('.'));

    if (lastDot > lastSlash)
        return fullPath.substring (lastSlash, lastDot);
    else
        return fullPath.substring (lastSlash);
}

works identical for folders and for files.
You could tell that I should check is it folder or file and change behavior of my program. I do this now. But maybe…
Any thinks?


#2

Sorry - don’t understand the question…! It just removes the bit of the filename that’s after the dot. Why would it matter whether it’s a directory?


#3

Ok.
I’ll try to improve my English.
Thanks for replying.


#4