Add a file_skip() routine to skip N bytes forward in the file - it's

currently just a wrapper around file_seek(), but could be implemented by
reading forward if, for example, we add support for reading
(sequentially only!) from a pipe.

Sort the declarations of file-reading routines into one block.

svn path=/trunk/; revision=42391
This commit is contained in:
Guy Harris 2012-05-02 21:25:48 +00:00
parent e1ee9ca907
commit ecacaacbe2
2 changed files with 19 additions and 7 deletions

View File

@ -1042,6 +1042,19 @@ file_seek(FILE_T file, gint64 offset, int whence, int *err)
return file->pos + offset;
}
/*
* Skip forward the specified number of bytes in the file.
* Currently implemented as a wrapper around file_seek(),
* but if, for example, we ever add support for reading
* sequentially from a pipe, this could instead just skip
* forward by reading the bytes in question.
*/
gint64
file_skip(FILE_T file, gint64 delta, int *err)
{
return file_seek(file, delta, SEEK_CUR, err);
}
gint64
file_tell(FILE_T stream)
{

View File

@ -27,22 +27,21 @@
#include <wtap.h>
#include <wsutil/file_util.h>
extern FILE_T file_open(const char *path);
extern FILE_T filed_open(int fildes);
extern void file_set_random_access(FILE_T stream, gboolean random, GPtrArray *seek);
extern gint64 file_seek(FILE_T stream, gint64 offset, int whence, int *err);
extern gint64 file_skip(FILE_T file, gint64 delta, int *err);
extern gint64 file_tell(FILE_T stream);
extern gint64 file_tell_raw(FILE_T stream);
extern int file_fstat(FILE_T stream, ws_statb64 *statb, int *err);
extern int file_error(FILE_T fh, gchar **err_info);
extern FILE_T file_open(const char *path);
extern FILE_T filed_open(int fildes);
extern int file_read(void *buf, unsigned int count, FILE_T file);
extern int file_close(FILE_T file);
extern int file_getc(FILE_T stream);
extern char *file_gets(char *buf, int len, FILE_T stream);
extern int file_eof(FILE_T stream);
extern int file_error(FILE_T fh, gchar **err_info);
extern void file_clearerr(FILE_T stream);
extern void file_set_random_access(FILE_T stream, gboolean random, GPtrArray *seek);
extern int file_close(FILE_T file);
#ifdef HAVE_LIBZ
typedef struct wtap_writer *GZWFILE_T;