Exemplo n.º 1
0
size_t FilePathGetPosSegment(OovStringRef const path, OovStringRef const seg)
{
    OovString lowerPath;
    // Only do case insensitive compares for Windows.
#ifdef __linux__
    lowerPath = path;
#else
    lowerPath.setLowerCase(path);
#endif
    OovString lowerSeg;
#ifdef __linux__
    lowerSeg = seg;
#else
    lowerSeg.setLowerCase(seg);
#endif
    size_t pos = lowerPath.find(lowerSeg);
    size_t foundPos = std::string::npos;
    if(pos != std::string::npos)
    {
        if(pos > 0)
        {
            size_t endPos = pos + lowerSeg.length();
            if(FilePathIsPathSep(path, pos-1) &&
                    FilePathIsPathSep(path, endPos))
            {
                foundPos = pos-1;
            }
        }
    }
    return foundPos;
}