Example #1
0
static bool checkRootPath(char* buff) {
    char* p;
    char tmp[512];
    int maxLevel, i , len;
    len = strlen(buff);


    maxLevel = 4;

    strcpy(tmp, buff);
    p = tmp+len-1;
    if(*p == '/') {
        *p = 0;
        p--;
    }

    for(i = 0; i < maxLevel; i++) {
        strcat(tmp, "/root/etc");
        if(cIOExistsPort(tmp)) {
            p[1] = 0;
            strcpy(buff, tmp);
            return true;
        }
        else {
            while(*p != '/') {
                p--;
            }
            *p = 0;
            p--;
        }
        if(p <= tmp)
            break;
    }

    strcpy(tmp, buff);
    p = tmp+len-1;
    if(*p == '/') {
        *p = 0;
        p--;
    }

    for(i = 0; i < maxLevel; i++) {
        strcat(tmp, "/projects/root/etc");
        if(cIOExistsPort(tmp)) {
            p[1+9] = 0;
            strcpy(buff, tmp);
            return true;
        }
        else {
            cTrace("%s not exist\n", tmp);
            while(*p != '/') {
                p--;
            }
            *p = 0;
            p--;
        }
        if(p <= tmp)
            break;
    }
    return false;
}
Example #2
0
bool cIOExists(const char* fname) {
    return cIOExistsPort(fname);
}