diff --git a/src/isotoserial.d b/src/isotoserial.d index 8e9ab4e..6b200c1 100644 --- a/src/isotoserial.d +++ b/src/isotoserial.d @@ -11,12 +11,14 @@ extern(C) { int scan_iso (const(char)* filename, iso_listing_callback callback, void* user_data); private int printer(void*, const(char)* path, int is_dir) { - writef("Entry \"%s\"", path.fromStringz); + auto spath = path.fromStringz; + + writef("Entry \"%s\"", spath); if (is_dir != 0) { write(" (directory)"); } write("\n"); - return 0; + return (spath == "/UMD_DATA.BIN" ? 1 : 0); } } diff --git a/subprojects/isoinfo/src/isoinfo.c b/subprojects/isoinfo/src/isoinfo.c index a3128b6..41362ec 100644 --- a/subprojects/isoinfo/src/isoinfo.c +++ b/subprojects/isoinfo/src/isoinfo.c @@ -199,7 +199,7 @@ LOCAL void extract_file __PR((struct scsi_dev *dev, int f, LOCAL void parse_cl_dir __PR((struct scsi_dev *dev, struct iso_directory_record *idr, int extent)); LOCAL BOOL parse_de __PR((struct iso_directory_record *idr)); -LOCAL void parse_dir __PR((struct scsi_dev *dev, struct todo *dp, +LOCAL int parse_dir __PR((struct scsi_dev *dev, struct todo *dp, char * rootname, int extent, int len, iso_listing_callback callback, void* user_data)); LOCAL void list_locales __PR((void)); @@ -902,7 +902,7 @@ parse_de(idr) return (TRUE); } -LOCAL void +LOCAL int parse_dir(dev, dp, rootname, extent, len, callback, user_data) struct scsi_dev *dev; struct todo *dp; @@ -922,6 +922,7 @@ parse_dir(dev, dp, rootname, extent, len, callback, user_data) int rlen; int blen; int rr_flags = 0; + int stop_now = 0; static char *n = 0; static int nlen = 0; @@ -988,7 +989,9 @@ static int nlen = 0; int nextent; struct todo *tp = dp; - (*callback)(user_data, n, 1); + stop_now = (*callback)(user_data, n, 1); + if (stop_now) + break; nextent = isonum_733((unsigned char *)idr->extent); while (tp) { @@ -1021,7 +1024,10 @@ static int nlen = 0; (idr->name[0] != 0 || idr->name[0] != 1)) { /* this is . or .. */ } else { - callback(user_data, n, 0); + stop_now = callback(user_data, n, 0); + if (stop_now) + break; + if (xtract && strcmp(xtract, n) == 0) { extract_file(dev, STDOUT_FILENO, idr, "stdout"); } @@ -1088,6 +1094,9 @@ static int nlen = 0; i += buffer[i]; if (i > 2048 - offsetof(struct iso_directory_record, name[0])) break; } + + if (stop_now) + break; } if (Xtract) { char *nm = strrchr(rootname, '/'); @@ -1095,6 +1104,7 @@ static int nlen = 0; if (nm != rootname) nm++; } + return stop_now; } EXPORT int @@ -1175,6 +1185,7 @@ run_scanning(dev, callback, user_data) struct iso_directory_record * idr; char *charset = NULL; int voldesc_sum = 0; + int stop_listing; char *cp; #if defined(USE_NLS) @@ -1357,11 +1368,13 @@ run_scanning(dev, callback, user_data) if (use_joliet) idr = (struct iso_directory_record *)jpd.root_directory_record; - parse_dir(dev, todo_idr, "/", isonum_733((unsigned char *)idr->extent), + stop_listing = parse_dir(dev, todo_idr, "/", + isonum_733((unsigned char *)idr->extent), isonum_733((unsigned char *)idr->size), callback, user_data); td = todo_idr; while (td) { - parse_dir(dev, td, td->name, td->extent, td->length, callback, user_data); + if (!stop_listing) + stop_listing = parse_dir(dev, td, td->name, td->extent, td->length, callback, user_data); free(td->name); td = td->next; }