http://d.puremagic.com/issues/show_bug.cgi?id=2767





------- Comment #3 from bugzi...@digitalmars.com  2009-03-29 01:35 -------
Brad makes a good point, there are aux:, lpt1:, prn:, com1:, etc. But they all
share the characteristic that the ':' is the last character. So, here's my
patch:

char *FileName::name(const char *str)
{
    char *e;
    size_t len = strlen(str);

    e = (char *)str + len;
    for (;;)
    {
        switch (*e)
        {
#if linux || __APPLE__ || __FreeBSD__
            case '/':
               return e + 1;
#endif
#if _WIN32
            case '/':
            case '\\':
                return e + 1;
            case ':':
                /* The ':' is a drive letter only if it is the second
                 * character or the last character,
                 * otherwise it is an ADS (Alternate Data Stream) separator.
                 * Consider ADS separators as part of the file name.
                 */
                if (e == str + 1 || e == str + len - 1)
                    return e + 1;
#endif
            default:
                if (e == str)
                    break;
                e--;
                continue;
        }
        return e;
    }
}


-- 

Reply via email to