1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* return true of char is "." or ".." */
#define DOT    ('.' << 8)
#define DOTDOT ('.' << 16 | DOT)
bool check_special_dirs(const char* name)
{
    int32_t val = name[0] << 8 | name[1];
    return (val == DOT) || ((((val<<8) | name[2]) == DOTDOT));
}

bool check_special_dirs2(const char* name)
{
    int char0 = name[0], char1 = name[1];
    if (char0 == '.')
    {
        if (!char0)
            return true;
        if (char1 == '.')
            return !name[2];
    }
    return false;
}

bool check_special_dirs3(const char* name)
{
    int char0 = name[0], char1 = name[1];
    if (char0 != '.')
        return false;
    if (!char0)
        return true;
    if (char1 == '.')
        return !name[2];
}