Exemplo n.º 1
0
Arquivo: skin.c Projeto: adaptee/fcitx
void LoadSkinDirectory(FcitxClassicUI* classicui)
{
    UT_array* skinBuf = &classicui->skinBuf;
    utarray_clear(skinBuf);
    int i ;
    DIR *dir;
    struct dirent *drt;
    size_t len;
    char **skinPath = FcitxXDGGetPathWithPrefix(&len, "skin");
    for (i = 0; i < len; i++) {
        dir = opendir(skinPath[i]);
        if (dir == NULL)
            continue;

        while ((drt = readdir(dir)) != NULL) {
            if (strcmp(drt->d_name , ".") == 0 ||
                strcmp(drt->d_name, "..") == 0)
                continue;
            char *pathBuf;
            fcitx_utils_alloc_cat_str(pathBuf, skinPath[i], "/", drt->d_name, "/fcitx_skin.conf");
            boolean result = fcitx_utils_isreg(pathBuf);
            free(pathBuf);
            if (result) {
                /* check duplicate name */
                int j = 0;
                for (; j < skinBuf->i; j++) {
                    char **name = (char**) utarray_eltptr(skinBuf, j);
                    if (strcmp(*name, drt->d_name) == 0)
                        break;
                }
                if (j == skinBuf->i) {
                    char *temp = drt->d_name;
                    utarray_push_back(skinBuf, &temp);
                }
            }
        }

        closedir(dir);
    }

    FcitxXDGFreePath(skinPath);

    return;
}
Exemplo n.º 2
0
void _fcitx_compose_table_find_system_compose_dir(FcitxComposeTable* table, int nPossibleLocation, const char* possibleLocation[]) {
    bool found = false;
    for (int i = 0; i < nPossibleLocation; ++i) {
        char* path;
        fcitx_utils_alloc_cat_str(path, possibleLocation[i], "/compose.dir");
        if (fcitx_utils_isreg(path)) {
            table->systemComposeDir = strdup(possibleLocation[i]);
            found = true;
        }

        free(path);

        if (found) {
            break;
        }
    }
    if (!found) {
        // should we ask to report this in the qt bug tracker?
        table->state = FCTS_UnknownSystemComposeDir;
    }
}