libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Libcdio-devel] [PATCH 1/4] Add read_iso_file helper function in iso


From: Rocky Bernstein
Subject: Re: [Libcdio-devel] [PATCH 1/4] Add read_iso_file helper function in iso-read
Date: Thu, 18 Oct 2012 20:03:06 -0400

Christophe -

Thanks for the enhancements and patches.

I tried applying the first patch to current git sources
(ff3eb9f22d6138fc85695f55ff66ec2e4c3837dc) r and I get:


  patching file src/iso-read.c
  Hunk #1 FAILED at 200.
  Hunk #2 FAILED at 274.
  2 out of 2 hunks FAILED -- saving rejects to file src/iso-read.c.rej

The file iso-read.c.rej is something that isn't easy to manually adjust
for. Could you try patching again against git source ffeb9f22 ... ?

Also please send the patch as an attachment. You can also attach patches as
a file at http://savannah.gnu.org/patch/?group=libcdio

This saves me the trouble of cutting and pasting email which is a potential
source of problem.

Thanks again,
   rocky

On Wed, Oct 17, 2012 at 7:45 AM, Christophe Fergeau <address@hidden>wrote:

> Move ISO9660 specific code to a helper function in preparation for
> adding UDF support to iso-read.
> ---
>  src/iso-read.c | 70
> ++++++++++++++++++++++++++++++++++++----------------------
>  1 file changed, 43 insertions(+), 27 deletions(-)
>
> diff --git a/src/iso-read.c b/src/iso-read.c
> index 4820887..707ceef 100644
> --- a/src/iso-read.c
> +++ b/src/iso-read.c
> @@ -200,54 +200,36 @@ init(void)
>    opts.iso9660_image = NULL;
>  }
>
> -int
> -main(int argc, char *argv[])
> +static int read_iso_file(const char *iso_name, const char *src,
> +                         FILE *outfd, size_t *bytes_written)
>  {
>    iso9660_stat_t *statbuf;
> -  FILE *outfd;
>    int i;
>    iso9660_t *iso;
> -
> -  init();
>
> -  /* Parse our arguments; every option seen by `parse_opt' will
> -     be reflected in `arguments'. */
> -  if (!parse_options(argc, argv)) {
> -    report(stderr,
> -          "error while parsing command line - try --help\n");
> -    return 2;
> -  }
> -
> -  iso = iso9660_open (opts.iso9660_image);
> +  iso = iso9660_open (iso_name);
>
>    if (NULL == iso) {
>      report(stderr,
>            "%s: Sorry, couldn't open ISO-9660 image file '%s'.\n",
> -          program_name, opts.iso9660_image);
> +          program_name, src);
>      return 1;
>    }
>
> -  statbuf = iso9660_ifs_stat_translate (iso, opts.file_name);
> +  statbuf = iso9660_ifs_stat_translate (iso, src);
>
>    if (NULL == statbuf)
>      {
>        report(stderr,
>              "%s: Could not get ISO-9660 file information out of %s"
>              " for file %s.\n",
> -            program_name, opts.iso9660_image, opts.file_name);
> +            program_name, iso_name, src);
>        report(stderr,
>              "%s: iso-info may be able to show the contents of %s.\n",
> -            program_name, opts.iso9660_image);
> +            program_name, iso_name);
>        return 2;
>      }
>
> -  if (!(outfd = fopen (opts.output_file, "wb")))
> -    {
> -      report(stderr,
> -            "%s: Could not open %s for writing: %s\n",
> -            program_name, opts.output_file, strerror(errno));
> -      return 3;
> -    }
>
>    /* Copy the blocks from the ISO-9660 filesystem to the local
> filesystem. */
>    for (i = 0; i < statbuf->size; i += ISO_BLOCKSIZE)
> @@ -274,16 +256,50 @@ main(int argc, char *argv[])
>           return 5;
>         }
>      }
> +  iso9660_close(iso);
> +
> +  *bytes_written = statbuf->size;
> +  return 0;
> +}
> +
> +int
> +main(int argc, char *argv[])
> +{
> +  FILE *outfd;
> +  int ret;
> +  size_t bytes_written;
> +
> +  init();
> +
> +  /* Parse our arguments; every option seen by `parse_opt' will
> +     be reflected in `arguments'. */
> +  if (!parse_options(argc, argv)) {
> +    report(stderr,
> +          "error while parsing command line - try --help\n");
> +    return 2;
> +  }
> +
> +  if (!(outfd = fopen (opts.output_file, "wb")))
> +    {
> +      report(stderr,
> +            "%s: Could not open %s for writing: %s\n",
> +            program_name, opts.output_file, strerror(errno));
> +      return 3;
> +    }
> +
> +  ret = read_iso_file (opts.iso9660_image, opts.file_name,
> +                       outfd, &bytes_written);
> +  if (ret != 0)
> +    return ret;
>
>    fflush (outfd);
>
>    /* Make sure the file size has the exact same byte size. Without the
>       truncate below, the file will a multiple of ISO_BLOCKSIZE.
>     */
> -  if (ftruncate (fileno (outfd), statbuf->size))
> +  if (ftruncate (fileno (outfd), bytes_written))
>      perror ("ftruncate()");
>
>    fclose (outfd);
> -  iso9660_close(iso);
>    return 0;
>  }
> --
> 1.7.12.1
>
>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]