From 383b010988bb6af62540cdb8efa76621ef25c162 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Mon, 14 Nov 2005 19:29:07 +0000 Subject: [PATCH] add fseek() --- libiso9660/iso9660_fseek.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 libiso9660/iso9660_fseek.c diff --git a/libiso9660/iso9660_fseek.c b/libiso9660/iso9660_fseek.c new file mode 100644 index 0000000..468891f --- /dev/null +++ b/libiso9660/iso9660_fseek.c @@ -0,0 +1,38 @@ +/* + * + * (c) 2005 Laurent Vivier + * + */ + +#include + +#include "libiso9660.h" + +extern iso9660_read_t __iso9660_device_read; + +int iso9660_fseek(iso9660_FILE *file, long offset, int whence) +{ + long new_offset; + + switch(whence) + { + case SEEK_SET: + new_offset = offset; + break; + case SEEK_CUR: + new_offset += offset; + break; + case SEEK_END: + new_offset = file->size + offset; + break; + default: + return -1; + } + + if ( (new_offset < 0) || (new_offset > file->size) ) + return -1; + + file->offset = offset; + + return 0; +}