diff options
author | Pixel <Pixel> | 2002-09-27 12:17:57 +0000 |
---|---|---|
committer | Pixel <Pixel> | 2002-09-27 12:17:57 +0000 |
commit | bfa5de7eccf4604ff8217f619e9685a09e80d545 (patch) | |
tree | a5be5de750ac611145f459a09bda902c3dbc1a70 /Xenogears/main_dump.cpp | |
parent | 60c1003845035ad4cd0e9ea50862bad7626faf0e (diff) |
The week-without-the-network changes
Diffstat (limited to 'Xenogears/main_dump.cpp')
-rw-r--r-- | Xenogears/main_dump.cpp | 77 |
1 files changed, 43 insertions, 34 deletions
diff --git a/Xenogears/main_dump.cpp b/Xenogears/main_dump.cpp index e380f7a..4a8cb2e 100644 --- a/Xenogears/main_dump.cpp +++ b/Xenogears/main_dump.cpp @@ -32,8 +32,21 @@ #include "generic.h" #include "Input.h" #include "Output.h" +#include "Main.h" +#include "cdabstract.h" + +CODE_BEGINS +public: +Appli() : tourne(0), nb_seqs(0), f_def(0), f_iso(0), cdutil(0) {} +virtual ~Appli() { + delete cdutil; + delete f_def; + delete f_iso; + delete f_out; +} +private: -unsigned int tourne = 0; +unsigned int tourne; struct t_index_tab { unsigned long address; @@ -52,19 +65,16 @@ struct t_sequence { String title, iso_filename, prefix; unsigned long iso_size; -unsigned int nb_records, nb_seqs = 0; +unsigned int nb_records, nb_seqs; struct t_sequence sequences[100]; +Handle * f_def, * f_iso, * f_out; -long check_iso(Handle * f_iso); -void read_files(Handle * f_iso); -void file_dump(Handle * f_iso, unsigned long debut, unsigned long taille, long num, int seq); -int process_def_file(Handle * f_def); +cdutils * cdutil; Byte user_data[2352]; -int Main(int argc, char **argv) +int startup() { - Handle * f_def, * f_iso; verbosity = 3; @@ -82,8 +92,7 @@ int Main(int argc, char **argv) f_def = new Input(argv[1]); - if (process_def_file(f_def)) { - delete f_def; + if (process_def_file()) { printm(M_ERROR, "Unable to process the definition file \"%s\"...\n", argv[1]); exit(-1); } @@ -91,24 +100,26 @@ int Main(int argc, char **argv) iso_filename = argv[2]; printm(M_STATUS, "Begin processing iso file.\n"); - f_iso = new Input(iso_filename); + f_iso = open_iso(iso_filename); - if (check_iso(f_iso)) { + if (check_iso()) { printm(M_ERROR, "Invalid iso file for " + title + "\n"); printm(M_ERROR, "===> Make sure you are using a Genuine iso file.\n"); } else { printm(M_INFO, "Genuine " + title + " iso detected.\n"); } + + cdutil = new cdutils(f_iso); + printm(M_STATUS, "Entering files read sequence\n"); - read_files(f_iso); - delete f_iso; + read_files(); exit(0); } /* * Ugly but working... for now */ -int process_def_file(Handle * f_def) +int process_def_file() { String t; unsigned int n, sum = 0; @@ -157,19 +168,23 @@ int process_def_file(Handle * f_def) } } -long check_iso(Handle * f_iso) +long check_iso() { unsigned long length; length = f_iso->GetSize(); - printm(M_INFO, "Filesize of iso file " + iso_filename + " is %ld bytes\n", length); - if (length != iso_size) { - return 1; + if (length < 0) { + printm(M_INFO, "Can not get file size, assuming reading from CD.\n"); + } else { + printm(M_INFO, "Filesize of iso file " + iso_filename + " is %ld bytes\n", length); + if (length != iso_size) { + return 1; + } } return 0; } -void read_files(Handle * f_iso) +void read_files() { t_index_tab index_tab[10000]; unsigned char t[8]; @@ -183,10 +198,10 @@ void read_files(Handle * f_iso) #define INDEXPOS 24 - sector_seek(f_iso, INDEXPOS); + cdutil->sector_seek(INDEXPOS); for (i = INDEXPOS; i < (INDEXPOS + 16); i++) { printm(M_INFO, "Reading fat sector %lu\n", i); - read_sector(f_iso, &fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1); + cdutil->read_sector(&fat[2048 * (i - INDEXPOS)], MODE_2_FORM_1); } indexer = 0; @@ -217,7 +232,7 @@ void read_files(Handle * f_iso) printm(M_INFO, "%6lu (%10lu): ignored\n", index_tab[i].address, index_tab[i].size); } else { printm(M_INFO, "%6lu (%10lu): ", index_tab[i].address, index_tab[i].size); - file_dump(f_iso, index_tab[i].address, index_tab[i].size, i, seq); + file_dump(index_tab[i].address, index_tab[i].size, i, seq); if (verbosity >= M_INFO) { fprintf(stderr, "\n"); } @@ -226,14 +241,13 @@ void read_files(Handle * f_iso) fprintf(stderr, "\n"); } -void file_dump(Handle * f_iso, unsigned long debut, unsigned long taille, long num, int seq) +void file_dump(unsigned long debut, unsigned long taille, long num, int seq) { long i; long nbsects; String nom; String extension = ".out"; String nom_t; - Handle * f_out; char type = sequences[seq].type; char ptitbidule[] = "-\\|/"; @@ -252,11 +266,11 @@ void file_dump(Handle * f_iso, unsigned long debut, unsigned long taille, long n nbsects = taille / sec_sizes[type]; if (taille % sec_sizes[type]) nbsects++; - sector_seek(f_iso, debut); + cdutil->sector_seek(debut); for (i = 0; i < nbsects; i++) { if (verbosity < M_INFO) fprintf(stderr, " (%c)\010\010\010\010\010", ptitbidule[((tourne++) >> 8) % 4]); - read_sector(f_iso, user_data, type); + cdutil->read_sector(user_data, type); if (i != (nbsects - 1)) { f_out->write(user_data, sec_sizes[type]); } else { @@ -264,13 +278,8 @@ void file_dump(Handle * f_iso, unsigned long debut, unsigned long taille, long n } } delete f_out; + f_out = 0; printm(M_BARE, " (*) Dumped file number %4ld - type \"" + sequences[seq].name + "\" \r", num); } -int main(int argc, char ** argv) { - try { - Main(argc, argv); - } catch (GeneralException e) { - fprintf(stderr, "Main got an unexpected exception: %s\n", e.GetMsg()); - } -} +} * Application = new Appli(); |