int main(int argc, const char *argv[]) { CdioList_t *entlist; CdioListNode_t *entnode; iso9660_t *p_iso = iso9660_open (ISO9660_IMAGE); if (NULL == p_iso) { fprintf(stderr, "Sorry, couldn't open ISO 9660 image %s\n", ISO9660_IMAGE); return 1; } entlist = iso9660_ifs_readdir (p_iso, "/"); /* Iterate over the list of nodes that iso9660_ifs_readdir gives */ _CDIO_LIST_FOREACH (entnode, entlist) { char filename[4096]; iso9660_stat_t *p_statbuf = (iso9660_stat_t *) _cdio_list_node_data (entnode); iso9660_name_translate(p_statbuf->filename, filename); printf ("/%s\n", filename); }
int main(int argc, const char *argv[]) { stat_vector_t stat_vector; ISO9660::FS *p_iso = new ISO9660::FS; char const *psz_fname; const char *psz_path="/"; ISO9660::PVD *p_pvd; if (argc > 1) psz_fname = argv[1]; else psz_fname = ISO9660_IMAGE; if (!p_iso->open(psz_fname, DRIVER_UNKNOWN)) { fprintf(stderr, "Sorry, couldn't open %s as a CD or CD image.\n", psz_fname); return 1; } p_pvd = p_iso->read_pvd(); if (p_pvd) { char *psz_str = NULL; print_vd_info("Application", get_application_id); print_vd_info("Preparer ", get_preparer_id); print_vd_info("Publisher ", get_publisher_id); print_vd_info("System ", get_system_id); print_vd_info("Volume ", get_volume_id); print_vd_info("Volume Set ", get_volumeset_id); } if (p_iso->readdir (psz_path, stat_vector)) { /* Iterate over the list of files. */ stat_vector_iterator_t i; for(i=stat_vector.begin(); i != stat_vector.end(); ++i) { char filename[4096]; ISO9660::Stat *p_s = *i; iso9660_name_translate(p_s->p_stat->filename, filename); printf ("%s [LSN %6d] %8u %s%s\n", 2 == p_s->p_stat->type ? "d" : "-", p_s->p_stat->lsn, p_s->p_stat->size, psz_path, filename); delete(p_s); } stat_vector.clear(); } delete(p_iso); return 0; }
int main(int argc, const char *argv[]) { CdioList_t *p_entlist; CdioListNode_t *p_entnode; char const *psz_fname; iso9660_t *p_iso; const char *psz_path="/"; if (argc > 1) psz_fname = argv[1]; else psz_fname = ISO9660_IMAGE; p_iso = iso9660_open (psz_fname); if (NULL == p_iso) { fprintf(stderr, "Sorry, couldn't open %s as an ISO-9660 image\n", psz_fname); return 1; } /* Show basic CD info from the Primary Volume Descriptor. */ { char *psz_str = NULL; print_vd_info("Application", iso9660_ifs_get_application_id); print_vd_info("Preparer ", iso9660_ifs_get_preparer_id); print_vd_info("Publisher ", iso9660_ifs_get_publisher_id); print_vd_info("System ", iso9660_ifs_get_system_id); print_vd_info("Volume ", iso9660_ifs_get_volume_id); print_vd_info("Volume Set ", iso9660_ifs_get_volumeset_id); } p_entlist = iso9660_ifs_readdir (p_iso, psz_path); /* Iterate over the list of nodes that iso9660_ifs_readdir gives */ if (p_entlist) { _CDIO_LIST_FOREACH (p_entnode, p_entlist) { char filename[4096]; iso9660_stat_t *p_statbuf = (iso9660_stat_t *) _cdio_list_node_data (p_entnode); iso9660_name_translate(p_statbuf->filename, filename); printf ("%s [LSN %6d] %8u %s%s\n", _STAT_DIR == p_statbuf->type ? "d" : "-", p_statbuf->lsn, p_statbuf->size, psz_path, filename); } _cdio_list_free (p_entlist, true); }
void DVDRipper::find_start_blocks() { CdioList_t *p_entlist; CdioListNode_t *p_entnode; if (!p_iso) return; p_entlist = iso9660_ifs_readdir (p_iso, "/video_ts/"); if (p_entlist) { _CDIO_LIST_FOREACH (p_entnode, p_entlist) { unsigned long long start; unsigned long long blocks; char filename[4096]; int len; iso9660_stat_t *p_statbuf = (iso9660_stat_t *) _cdio_list_node_data (p_entnode); iso9660_name_translate(p_statbuf->filename, filename); len = strlen(filename); if (!(2 == p_statbuf->type) ) { if (! strcmp(filename + (len-3), "vob")) { start = p_statbuf->lsn; blocks = CEILING(p_statbuf->size, DVDCSS_BLOCK_SIZE); start_map[start] = strdup(filename); if (blocks == 0) { //file length of 0 would result in a blocks of 0, and don't want //to subtract one from it. end_blocks[start] = start; } else { //-1 as start block is included in count of blocks end_blocks[start] = start - 1 + blocks; } printf("%s: %llu->%llu (%llu blocks)\n", filename, start, end_blocks[start], blocks); if (blocks) { if (find(start_blocks.begin(), start_blocks.end(), start) == start_blocks.end()) { start_blocks.push_back(start); } } } } } _cdio_list_free (p_entlist, true); }
int main(int argc, const char *argv[]) { CdioList_t *entlist; CdioListNode_t *entnode; char const *psz_fname; iso9660_t *p_iso; if (argc > 1) psz_fname = argv[1]; else psz_fname = ISO9660_IMAGE; p_iso = iso9660_open_fuzzy (psz_fname, 5); if (NULL == p_iso) { fprintf(stderr, "Sorry, could not find an ISO 9660 image from %s\n", psz_fname); return 1; } entlist = iso9660_ifs_readdir (p_iso, "/"); /* Iterate over the list of nodes that iso9660_ifs_readdir gives */ if (entlist) { _CDIO_LIST_FOREACH (entnode, entlist) { char filename[4096]; iso9660_stat_t *p_statbuf = (iso9660_stat_t *) _cdio_list_node_data (entnode); iso9660_name_translate(p_statbuf->filename, filename); printf ("/%s\n", filename); } _cdio_list_free (entlist, true); }
int main(int argc, const char *argv[]) { iso9660_stat_t *p_statbuf; FILE *p_outfd; int i; char const *psz_image; char const *psz_fname; char translated_name[256]; char untranslated_name[256] = ISO9660_PATH; CdIo_t *p_cdio; unsigned int i_fname=sizeof(ISO9660_FILENAME); if (argc > 3) { printf("usage %s [CD-ROM-or-image [filename]]\n", argv[0]); printf("Extracts filename from CD-ROM-or-image.\n"); return 1; } if (argc > 1) psz_image = argv[1]; else psz_image = ISO9660_IMAGE; if (argc > 2) { psz_fname = argv[2]; i_fname = strlen(psz_fname)+1; } else psz_fname = ISO9660_FILENAME; strncat(untranslated_name, psz_fname, i_fname); p_cdio = cdio_open (psz_image, DRIVER_UNKNOWN); if (!p_cdio) { fprintf(stderr, "Sorry, couldn't open %s\n", psz_image); return 1; } p_statbuf = iso9660_fs_stat (p_cdio, untranslated_name); if (NULL == p_statbuf) { fprintf(stderr, "Could not get ISO-9660 file information for file %s\n", untranslated_name); cdio_destroy(p_cdio); return 2; } iso9660_name_translate(psz_fname, translated_name); if (!(p_outfd = fopen (translated_name, "wb"))) { perror ("fopen()"); cdio_destroy(p_cdio); free(p_statbuf); return 3; } /* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */ { const unsigned int i_blocks = CEILING(p_statbuf->size, ISO_BLOCKSIZE); for (i = 0; i < i_blocks; i ++) { char buf[ISO_BLOCKSIZE]; const lsn_t lsn = p_statbuf->lsn + i; memset (buf, 0, ISO_BLOCKSIZE); if ( 0 != cdio_read_data_sectors (p_cdio, buf, lsn, ISO_BLOCKSIZE, 1) ) { fprintf(stderr, "Error reading ISO 9660 file at lsn %lu\n", (long unsigned int) p_statbuf->lsn); my_exit(4); } fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd); if (ferror (p_outfd)) { perror ("fwrite()"); my_exit(5); } } } fflush (p_outfd); /* Make sure the file size has the exact same byte size. Without the truncate below, the file will a multiple of ISO_BLOCKSIZE. */ if (ftruncate (fileno (p_outfd), p_statbuf->size)) perror ("ftruncate()"); printf("Extraction of file '%s' from '%s' successful.\n", translated_name, untranslated_name); my_exit(0); }
int main(int argc, const char *argv[]) { ISO9660::Stat *p_stat; FILE *p_outfd; unsigned int i; char const *psz_image; char const *psz_fname; char translated_name[256]; char untranslated_name[256] = ISO9660_PATH; ISO9660::FS *p_iso = new ISO9660::FS; if (argc > 3) { printf("usage %s [CD-ROM-or-image [filename]]\n", argv[0]); printf("Extracts filename from CD-ROM-or-image.\n"); return 1; } if (argc > 1) psz_image = argv[1]; else psz_image = ISO9660_IMAGE; if (argc > 2) psz_fname = argv[2]; else psz_fname = ISO9660_FILENAME; strcat(untranslated_name, psz_fname); if (!p_iso->open(psz_image, DRIVER_UNKNOWN)) { fprintf(stderr, "Sorry, couldn't open %s\n", psz_image); return 1; } p_stat = p_iso->stat(psz_fname); if (!p_stat) { fprintf(stderr, "Could not get ISO-9660 file information for file %s\n", untranslated_name); delete(p_iso); return 2; } iso9660_name_translate(psz_fname, translated_name); if (!(p_outfd = fopen (translated_name, "wb"))) { perror ("fopen()"); delete (p_stat); delete (p_iso); return 3; } /* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */ { const unsigned int i_blocks = CEILING(p_stat->p_stat->size, ISO_BLOCKSIZE); for (i = 0; i < i_blocks; i ++) { char buf[ISO_BLOCKSIZE]; const lsn_t lsn = p_stat->p_stat->lsn + i; memset (buf, 0, ISO_BLOCKSIZE); try { p_iso->readDataBlocks(buf, lsn, ISO_BLOCKSIZE); } catch ( DriverOpException e ) { fprintf(stderr, "Error reading ISO 9660 file at lsn %lu:\n\t%s.\n", (long unsigned int) lsn, e.get_msg()); my_exit(4); } fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd); if (ferror (p_outfd)) { perror ("fwrite()"); my_exit(5); } } } fflush (p_outfd); /* Make sure the file size has the exact same byte size. Without the truncate below, the file will a multiple of ISO_BLOCKSIZE. */ if (ftruncate (fileno (p_outfd), p_stat->p_stat->size)) perror ("ftruncate()"); printf("Extraction of file '%s' from '%s' successful.\n", translated_name, untranslated_name); my_exit(0); }