Пример #1
0
/*
=======================================
    写入选择结果
=======================================
*/
CR_API void_t
ximp_dir_write (
  __CR_IN__ const ansi_t*   path
    )
{
    FILE*   fp;

    fp = fopen(QST_SELECT_DIR, "w");
    if (fp != NULL) {
        file_deleteA(QST_STOPS_NEXT);
        fprintf(fp, "%s", path);
        fclose(fp);
    }
}
Пример #2
0
/*
=======================================
    主程序
=======================================
*/
int main (int argc, char *argv[])
{
    fbuf_t file;
    const ansi_t *root;

    /* 建立 CrHack 系统 */
    if (!set_app_type(CR_APP_CUI))
        return (QST_ERROR);

    /* 参数解析 [搜索根目录] */
    if (argc < 1) {
        printf("filehash [directory]\n");
        return (QST_ERROR);
    }

    /* 生成性能测试对象 */
    s_profile = timer_new();

    /* 生成输出文件 */
    file_deleteA("__hash__.old");
    file_renameA("__hash__.old", "__hash__.txt");
    file = file_buf_openA("__hash__.txt", CR_FO_WO);
    if (file == NULL) {
        printf("can't create output file\n");
        return (QST_ERROR);
    }

    /* 枚举所有文件 */
    if (argc == 1)
        root = "";
    else
        root = argv[1];
    s_rdata = NULL;
    mem_info(&s_total, &s_avail);
    s_total = (s_total * 618) / 1000;
    file_searchA(root, TRUE, FALSE, FALSE, "*.*", hasher, file);

    /* 释放内存 */
    file_buf_close(file);
    timer_del(s_profile);
    TRY_FREE(s_rdata);
    return (QST_OKAY);
}
Пример #3
0
/*
=======================================
    ARGB 文件保存
=======================================
*/
CR_API bool_t
save_img_argb (
  __CR_IN__ const sIMAGE*   img,
  __CR_IN__ const ansi_t*   name,
  __CR_IN__ uint_t          argc,
  __CR_IN__ ansi_t*         argv[]
    )
{
    uint_t  hh;
    leng_t  back;
    leng_t  nbpl;
    int32u  vals;
    file_t  file;
    byte_t* line;
    sIMAGE* cnvt;

    /* 创建文件 */
    CR_NOUSE(argc); CR_NOUSE(argv);
    file = file_openA(name, CR_FO_WO);
    if (file == NULL)
        return (FALSE);

    /* 保存文件头 */
    if (!file_putd(mk_tag4("BGRA"), file))
        goto _failure;
    if (!file_putd(0x08080808UL, file))
        goto _failure;
    vals = img->position.ww;
    if (!file_putd_le(vals, file))
        goto _failure;
    vals = img->position.hh;
    if (!file_putd_le(vals, file))
        goto _failure;

    /* 转换格式 */
    if (img->fmt == CR_ARGB8888) {
        cnvt = (sIMAGE*)img;
    }
    else {
        cnvt = img_auto_to_32(NULL, 0, 0, img);
        if (cnvt == NULL)
            goto _failure;
    }

    /* 写入文件 */
    line = cnvt->data;
    hh   = cnvt->position.hh;
    nbpl = cnvt->position.ww;
    nbpl *= sizeof(int32u);
    if (cnvt->gdi)
        line += cnvt->size - cnvt->bpl;
    for (; hh != 0; hh--) {
        back = file_write(line, nbpl, file);
        if (back != nbpl) {
            if (cnvt != (sIMAGE*)img)
                image_del(cnvt);
            goto _failure;
        }
        if (cnvt->gdi)
            line -= cnvt->bpl;
        else
            line += cnvt->bpl;
    }
    if (cnvt != (sIMAGE*)img)
        image_del(cnvt);
    file_close(file);
    return (TRUE);

_failure:
    file_close(file);
    file_deleteA(name);
    return (FALSE);
}