Esempio n. 1
0
// For some distros, we don't want to use the full version from VERSION_ID. One example is
// Red Hat Enterprise Linux, which includes a minor version in their VERSION_ID but minor
// versions are backwards compatable.
//
// In this case, we'll normalized RIDs like 'rhel.7.2' and 'rhel.7.3' to a generic
// 'rhel.7'. This brings RHEL in line with other distros like CentOS or Debian which
// don't put minor version numbers in their VERSION_ID fields because all minor versions
// are backwards compatible.
static
pal::string_t normalize_linux_rid(pal::string_t rid)
{
    pal::string_t rhelPrefix(_X("rhel."));

    if (rid.compare(0, rhelPrefix.length(), rhelPrefix) == 0)
    {
        size_t minorVersionSeparatorIndex = rid.find(_X("."), rhelPrefix.length());
        if (minorVersionSeparatorIndex != std::string::npos)
        {
            rid.erase(minorVersionSeparatorIndex, rid.length() - minorVersionSeparatorIndex);
        }
    }

    return rid;
}
Esempio n. 2
0
bool LongFile::IsUNCExtended(const pal::string_t& path)
{
    return path.compare(0, UNCExtendedPathPrefix.length(), UNCExtendedPathPrefix) == 0;
}
Esempio n. 3
0
bool LongFile::IsDevice(const pal::string_t& path)
{
    return path.compare(0, DevicePathPrefix.length(), DevicePathPrefix) == 0;
}
Esempio n. 4
0
bool ends_with(const pal::string_t& value, const pal::string_t& suffix)
{
    return suffix.length() <= value.length() &&
        (0 == value.compare(value.length() - suffix.length(), suffix.length(), suffix));
}