[FFmpeg-devel] [PATCH] Add av_file_get_size() and av_file_read(), replace cmdutils.h:read_file().
Stefano Sabatini
stefano.sabatini-lala
Mon Nov 29 12:54:37 CET 2010
On date Monday 2010-11-29 12:25:34 +0100, Stefano Sabatini encoded:
> On date Friday 2010-11-26 14:15:47 +0100, Aurelien Jacobs encoded:
> > On Fri, Nov 26, 2010 at 01:25:37PM +0100, Stefano Sabatini wrote:
> > > On date Friday 2010-11-26 01:32:11 +0100, Stefano Sabatini encoded:
> > > > ---
> > > > cmdutils.c | 24 ---------------------
> > > > cmdutils.h | 11 ----------
> > > > ffmpeg.c | 3 +-
> > > > libavutil/Makefile | 2 +
> > > > libavutil/file.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > > libavutil/file.h | 43 +++++++++++++++++++++++++++++++++++++++
> > > > 6 files changed, 104 insertions(+), 36 deletions(-)
> > > > create mode 100644 libavutil/file.c
> > > > create mode 100644 libavutil/file.h
> > >
> > > Updated with fixes.
> >
> > > From 68b5d5f1806a92ffe8743a48c5064f29a35841b1 Mon Sep 17 00:00:00 2001
> > > From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> > > Date: Fri, 26 Nov 2010 01:27:58 +0100
> > > Subject: [PATCH] Add av_file_get_size() and av_file_read(), replace
> > > cmdutils.h:read_file().
> > >
> > > ---
> > > cmdutils.c | 24 ---------------------
> > > cmdutils.h | 11 ---------
> > > ffmpeg.c | 3 +-
> > > libavutil/Makefile | 2 +
> > > libavutil/file.c | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > libavutil/file.h | 45 +++++++++++++++++++++++++++++++++++++++
> > > 6 files changed, 108 insertions(+), 36 deletions(-)
> > > create mode 100644 libavutil/file.c
> > > create mode 100644 libavutil/file.h
> > >
> > > diff --git a/libavutil/file.c b/libavutil/file.c
> > > new file mode 100644
> > > index 0000000..530d421
> > > --- /dev/null
> > > +++ b/libavutil/file.c
> > > @@ -0,0 +1,59 @@
> > > +/*
> > > + * This file is part of FFmpeg.
> > > + *
> > > + * FFmpeg is free software; you can redistribute it and/or
> > > + * modify it under the terms of the GNU Lesser General Public
> > > + * License as published by the Free Software Foundation; either
> > > + * version 2.1 of the License, or (at your option) any later version.
> > > + *
> > > + * FFmpeg is distributed in the hope that it will be useful,
> > > + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> > > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> > > + * Lesser General Public License for more details.
> > > + *
> > > + * You should have received a copy of the GNU Lesser General Public
> > > + * License along with FFmpeg; if not, write to the Free Software
> > > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> > > + */
> > > +
> > > +#include "file.h"
> > > +
> > > +size_t av_file_get_size(FILE *file)
> > > +{
> > > + size_t size;
> > > +
> > > + fseek(file, 0, SEEK_END);
> > > + size = ftell(file);
> > > + fseek(file, 0, SEEK_SET);
> > > +
> > > + return size;
> > > +}
> >
> > This will not only return file size but also seek to the begining of the
> > file, which may not be desired, especially for a public API.
> > Using fstat() seems more appropriate to get a file size.
> >
> > And overall, I wonder why you used the buffered stream API (fopen())
> > instead of raw file access (open()) ?
>
> I mindlessly adapted the code of read_file(). I removed the
> av_file_get_size() which isn't currently used and updated the patch.
> --
> FFmpeg = Frenzy and Fast MultiPurpose Ecletic Gadget
> From f377c5f841929834f5ca89d0e4c9ce1154e4a8f6 Mon Sep 17 00:00:00 2001
> From: Stefano Sabatini <stefano.sabatini-lala at poste.it>
> Date: Fri, 26 Nov 2010 01:27:58 +0100
> Subject: [PATCH] Add av_file_read(), replace cmdutils.h:read_file().
Added support for symbolic link files.
--
FFmpeg = Frightening and Faithful Moronic Pitiful EniGma
More information about the ffmpeg-devel
mailing list