Ejemplo n.º 1
0
static imgtoolerr_t lookup_rsdos_file(imgtool::image &f, const char *fname, rsdos_dirent &ent, int *position = nullptr)
{
	int i;
	floperr_t ferr;
	std::string fnamebuf;

	i = 0;

	do
	{
		do
		{
			ferr = get_rsdos_dirent(f, i++, ent);
			if (ferr)
				return imgtool_floppy_error(ferr);
		}
		while(ent.filename[0] == '\0');


		if (ent.filename[0] != -1)
			fnamebuf = get_dirent_fname(ent);
	}
	while((ent.filename[0] != -1) && core_stricmp(fnamebuf.c_str(), fname));

	if (ent.filename[0] == -1)
		return IMGTOOLERR_FILENOTFOUND;

	if (position)
		*position = i - 1;
	return (imgtoolerr_t)0;
}
Ejemplo n.º 2
0
static imgtoolerr_t lookup_rsdos_file(imgtool_image *f, const char *fname, struct rsdos_dirent *ent, int *position)
{
    int i;
    floperr_t ferr;
    char fnamebuf[13];

    i = 0;
    fnamebuf[0] = '\0';

    do
    {
        do
        {
            ferr = get_rsdos_dirent(f, i++, ent);
            if (ferr)
                return imgtool_floppy_error(ferr);
        }
        while(ent->fname[0] == '\0');


        if (ent->fname[0] != -1)
            get_dirent_fname(fnamebuf, ent);
    }
    while((ent->fname[0] != -1) && core_stricmp(fnamebuf, fname));

    if (ent->fname[0] == -1)
        return IMGTOOLERR_FILENOTFOUND;

    if (position)
        *position = i - 1;
    return (imgtoolerr_t)0;
}
Ejemplo n.º 3
0
static imgtoolerr_t rsdos_diskimage_nextenum(imgtool::directory &enumeration, imgtool_dirent &ent)
{
	floperr_t ferr;
	imgtoolerr_t err;
	size_t filesize;
	rsdos_direnum *rsenum;
	rsdos_dirent rsent;

	imgtool::image &image(enumeration.image());
	rsenum = (rsdos_direnum *) enumeration.extra_bytes();

	/* Did we hit the end of file before? */
	if (rsenum->eof)
		goto eof;

	do
	{
		if (rsenum->index >= MAX_DIRENTS)
			goto eof;

		ferr = get_rsdos_dirent(image, rsenum->index++, rsent);
		if (ferr)
			return imgtool_floppy_error(ferr);
	}
	while(rsent.filename[0] == '\0');

	// now are we at the eof point?
	if (rsent.filename[0] == -1)
	{
		rsenum->eof = 1;
eof:
		ent.eof = 1;
	}
	else
	{
		/* Not the end of file */
		err = process_rsdos_file(&rsent, image, nullptr, filesize);
		if (err)
			return err;

		if (filesize == ((size_t) -1))
		{
			/* corrupt! */
			ent.filesize = 0;
			ent.corrupt = 1;
		}
		else
		{
			ent.filesize = filesize;
			ent.corrupt = 0;
		}
		ent.eof = 0;

		std::string fname = get_dirent_fname(rsent);

		snprintf(ent.filename, ARRAY_LENGTH(ent.filename), "%s", fname.c_str());
		snprintf(ent.attr, ARRAY_LENGTH(ent.attr), "%d %c", (int) rsent.ftype, (char) (rsent.asciiflag + 'B'));
	}
	return IMGTOOLERR_SUCCESS;
}
Ejemplo n.º 4
0
static imgtoolerr_t rsdos_diskimage_nextenum(imgtool_directory *enumeration, imgtool_dirent *ent)
{
    floperr_t ferr;
    imgtoolerr_t err;
    size_t filesize;
    struct rsdos_direnum *rsenum;
    struct rsdos_dirent rsent;
    char fname[13];
    imgtool_image *image;

    image = imgtool_directory_image(enumeration);
    rsenum = (struct rsdos_direnum *) imgtool_directory_extrabytes(enumeration);

    /* Did we hit the end of file before? */
    if (rsenum->eof)
        goto eof;

    do
    {
        if (rsenum->index >= MAX_DIRENTS)
            goto eof;

        ferr = get_rsdos_dirent(image, rsenum->index++, &rsent);
        if (ferr)
            return imgtool_floppy_error(ferr);
    }
    while(rsent.fname[0] == '\0');

    /* Now are we at the eof point? */
    if (rsent.fname[0] == -1)
    {
        rsenum->eof = 1;
eof:
        ent->eof = 1;
    }
    else
    {
        /* Not the end of file */
        err = process_rsdos_file(&rsent, image, NULL, &filesize);
        if (err)
            return err;

        if (filesize == ((size_t) -1))
        {
            /* corrupt! */
            ent->filesize = 0;
            ent->corrupt = 1;
        }
        else
        {
            ent->filesize = filesize;
            ent->corrupt = 0;
        }
        ent->eof = 0;

        get_dirent_fname(fname, &rsent);

        snprintf(ent->filename, ARRAY_LENGTH(ent->filename), "%s", fname);
        snprintf(ent->attr, ARRAY_LENGTH(ent->attr), "%d %c", (int) rsent.ftype, (char) (rsent.asciiflag + 'B'));
    }
    return IMGTOOLERR_SUCCESS;
}