コード例 #1
0
ファイル: ece391grep.c プロジェクト: AeroHand/XiOS
int main ()
{
    int32_t fd, cnt;
    uint8_t buf[SBUFSIZE];
    uint8_t search[BUFSIZE];

    if (0 != ece391_getargs (search, BUFSIZE)) {
        ece391_fdputs (1, (uint8_t*)"could not read argument\n");
        return 3;
    }

    if (-1 == (fd = ece391_open ((uint8_t*)"."))) {
        ece391_fdputs (1, (uint8_t*)"directory open failed\n");
	return 2;
    }

    while (0 != (cnt = ece391_read (fd, buf, SBUFSIZE-1))) {
        if (-1 == cnt) {
	    ece391_fdputs (1, (uint8_t*)"directory entry read failed\n");
	    return 3;
	}
	if ('.' == buf[0]) /* a directory... */
	    continue;
	buf[cnt] = '\0';
	if (0 != do_one_file ((char*)search, (char*)buf))
	    return 3;
    }

    return 0;
}
コード例 #2
0
ファイル: synctest.c プロジェクト: ZhuoyuZhang/testunion
void do_child(void)
{
    int fileno;
    char *dn = mk_dirname();
    int dotcount;

    dir_fd = open(dn, O_RDONLY);
    if (dir_fd < 0) {
        fprintf(stderr, "%s: failed to open dir `%s': %s\n",
                progname, dn, strerror(errno));
        exit(1);
    }
    free(dn);

    dotcount = N_FILES / 10;
    if (dotcount == 0)
        dotcount = 1;

    for (fileno = 0; fileno < N_FILES; fileno++) {
        if (fileno % dotcount == 0) {
            printf(".");
            fflush(stdout);
        }
        do_one_file(fileno);
        if (fileno >= UNLINK_LAG)
            unlink_one_file(fileno - UNLINK_LAG, RENAME_PASSES - 1);
    }
    for (fileno = N_FILES - UNLINK_LAG; fileno < N_FILES; fileno++)
        unlink_one_file(fileno, RENAME_PASSES - 1);
}
コード例 #3
0
ファイル: work.cpp プロジェクト: tfauck/upx
void do_files(int i, int argc, char *argv[])
{
    if (opt->verbose >= 1)
    {
        show_head();
        UiPacker::uiHeader();
    }

    for ( ; i < argc; i++)
    {
        infoHeader();

        const char *iname = argv[i];
        char oname[ACC_FN_PATH_MAX+1];
        oname[0] = 0;

        try {
            do_one_file(iname,oname);
        } catch (const Exception &e) {
            unlink_ofile(oname);
            if (opt->verbose >= 1 || (opt->verbose >= 0 && !e.isWarning()))
                printErr(iname,&e);
            set_exit_code(e.isWarning() ? EXIT_WARN : EXIT_ERROR);
        } catch (const Error &e) {
            unlink_ofile(oname);
            printErr(iname,&e);
            e_exit(EXIT_ERROR);
        } catch (std::bad_alloc *e) {
            unlink_ofile(oname);
            printErr(iname,"out of memory");
            UNUSED(e);
            //delete e;
            e_exit(EXIT_ERROR);
        } catch (const std::bad_alloc &) {
            unlink_ofile(oname);
            printErr(iname,"out of memory");
            e_exit(EXIT_ERROR);
        } catch (std::exception *e) {
            unlink_ofile(oname);
            printUnhandledException(iname,e);
            //delete e;
            e_exit(EXIT_ERROR);
        } catch (const std::exception &e) {
            unlink_ofile(oname);
            printUnhandledException(iname,&e);
            e_exit(EXIT_ERROR);
        } catch (...) {
            unlink_ofile(oname);
            printUnhandledException(iname,NULL);
            e_exit(EXIT_ERROR);
        }
    }

    if (opt->cmd == CMD_COMPRESS)
        UiPacker::uiPackTotal();
    else if (opt->cmd == CMD_DECOMPRESS)
        UiPacker::uiUnpackTotal();
    else if (opt->cmd == CMD_LIST)
        UiPacker::uiListTotal();
    else if (opt->cmd == CMD_TEST)
        UiPacker::uiTestTotal();
    else if (opt->cmd == CMD_FILEINFO)
        UiPacker::uiFileInfoTotal();
}