diff options
Diffstat (limited to 'Xenogears/reinsert.cpp')
-rw-r--r-- | Xenogears/reinsert.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Xenogears/reinsert.cpp b/Xenogears/reinsert.cpp index e58b871..d6e0a4c 100644 --- a/Xenogears/reinsert.cpp +++ b/Xenogears/reinsert.cpp @@ -1,6 +1,7 @@ #include <stdio.h> #include <string.h> #include <stdlib.h> +#include <unistd.h> #include "fileutils.h" #include "cdutils.h" #include "generic.h" @@ -22,7 +23,7 @@ struct t_sequence { int type; }; -char *title, *iso_filename, *tbl_filename, *prefix, *in_filename; +char *title, *iso_filename, *prefix, *in_filename; unsigned long iso_size; unsigned int nb_records, nb_seqs = 0; struct t_sequence sequences[1000]; @@ -31,7 +32,7 @@ int slus_index = -1, force = 0; long check_iso(int f_iso); void write_files(int f_iso_r, int f_iso_w, int f_in, int fileindex); -int process_def_file(int f_def); +int process_def_file(int f_def); unsigned char user_data[2352]; @@ -87,10 +88,16 @@ int main(int argc, char **argv) printm(M_ERROR, "Unable to open the iso file \"%s\"...\n", iso_filename); exit(-1); } + + if (lseek(f_iso_w, 0, SEEK_SET)) { + printm(M_ERROR, "Can't rewind the file\n"); + exit(-1); + } if (check_iso(f_iso_r)) { printm(M_ERROR, "Invalid iso file for %s\n", title); printm(M_ERROR, "===> Make sure you are using a Genuine iso file.\n"); + exit(-1); } else { printm(M_INFO, "Genuine %s iso detected.\n", title); } @@ -112,11 +119,11 @@ int main(int argc, char **argv) /* * Ugly but working... for now */ -int process_def_file(int h_f_def) +int process_def_file(int ff_def) { char t[1024], *p; + FILE * f_def = fdopen(ff_def, "r"); unsigned int n, sum = 0; - FILE * f_def = fdopen(h_f_def, "r"); if ((p = strchr(fgets(t, 1024, f_def), '\n')) == NULL) return 1; @@ -131,12 +138,6 @@ int process_def_file(int h_f_def) if ((p = strchr(fgets(t, 1024, f_def), '\n')) == NULL) return 1; *p = 0; - printm(M_INFO, "Read index table filename: %s\n", t); - tbl_filename = strdup(t); - - if ((p = strchr(fgets(t, 1024, f_def), '\n')) == NULL) - return 1; - *p = 0; printm(M_INFO, "Read global directory prefix: %s\n", t); prefix = strdup(t); |