Logo Search packages:      
Sourcecode: fcitx version File versions  Download package

void SaveConfig ( void   )

保存配置信息

Definition at line 1306 of file tools.c.

References write_configures().

Referenced by LoadConfig(), and LoadProfile().

{
    FILE    *fp;
    char    buf[PATH_MAX], *pbuf;
    Configure_group *tmpgroup;

    pbuf = getenv("HOME");
    if(!pbuf){
        fprintf(stderr, "error: get environment variable HOME\n");
        exit(1);
    }

    snprintf(buf, PATH_MAX, "%s/.fcitx", pbuf);
    if(mkdir(buf, S_IRWXU) < 0 && errno != EEXIST){
        perror("mkdir");
        exit(1);
    }

    snprintf(buf, PATH_MAX, "%s/.fcitx/config", pbuf);
    fp = fopen (buf, "w");
    if (!fp) {
        perror("fopen");
        exit(1);
    }

    /* 实际上,写配置文件很简单,就是从全局数组configure_groups里面分别把每个组的配置
     * 写入到文件里面去*/
    for(tmpgroup = configure_groups; tmpgroup->name; tmpgroup++){
        if(tmpgroup->comment)
            fprintf(fp, "# %s\n", tmpgroup->comment); // 如果存在注释,先写入
        fprintf(fp, "[%s]\n", tmpgroup->name);              // 接下来写入组的名字
        write_configures(fp, tmpgroup->configure);          /* 最后将该组的每个配置项
                                                                                     * 写入到文件中*/
        fprintf(fp, "\n");          // 为增加可读性插入一个空行
    }
    fclose(fp);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index