i would think that a more complete solution
would be something like this.  (not tested)
0xff isn't delete, and isn't valid utf.  0x7f is
valid utf, but also not useful in a file name.

- erik

int
checkname(char *s)
{
        int i, n;
        Rune c;

        if(s == nil || *s == 0)
                return Ename;
        if(*s == '.' && (s[1] == 0 || (s[1] == '.' && s[2] == 0)))
                return Edot;
        for(i = 0;; i += n) {
                n = chartorune(&r, s);
                if(i+n >= NAMELEN)
                        return Etoolong;
                if(r == 0)
                        return 0;
                if(n == 1 && r == Runeerror)
                        return Ename;
                if(r <= 040 || r == 0x7f)
                        return Ename;
        }
}

Reply via email to