static void print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[], cdio_fs_anal_t fs) { CdioList_t *p_entlist; CdioList_t *p_dirlist = _cdio_list_new (); CdioListNode_t *entnode; uint8_t i_joliet_level; i_joliet_level = (opts.no_joliet) ? 0 : cdio_get_joliet_level(p_cdio); p_entlist = iso9660_fs_readdir (p_cdio, pathname, false); printf ("%s:\n", pathname); if (NULL == p_entlist) { report( stderr, "Error getting above directory information\n" ); return; } /* Iterate over files in this directory */ _CDIO_LIST_FOREACH (entnode, p_entlist) { iso9660_stat_t *p_statbuf = _cdio_list_node_data (entnode); char *psz_iso_name = p_statbuf->filename; char _fullname[4096] = { 0, }; char translated_name[MAX_ISONAME+1]; if (yep != p_statbuf->rr.b3_rock || 1 == opts.no_rock_ridge) { iso9660_name_translate_ext(psz_iso_name, translated_name, i_joliet_level); } snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, psz_iso_name); strncat (_fullname, "/", sizeof (_fullname)); if (p_statbuf->type == _STAT_DIR && strcmp (psz_iso_name, ".") && strcmp (psz_iso_name, "..")) _cdio_list_append (p_dirlist, strdup (_fullname)); print_fs_attrs(p_statbuf, 0 == opts.no_rock_ridge, fs & CDIO_FS_ANAL_XA, psz_iso_name, translated_name); if (p_statbuf->rr.i_symlink) { free(p_statbuf->rr.psz_symlink); p_statbuf->rr.i_symlink = 0; } }
/*! Read psz_path (a directory) and return a list of iso9660_stat_t pointers for the files inside that directory. The caller must free the returned result. */ bool ISO9660::FS::readdir (const char psz_path[], stat_vector_t& stat_vector, bool b_mode2) { CdioList_t * p_stat_list = iso9660_fs_readdir (p_cdio, psz_path, b_mode2); if (p_stat_list) { CdioListNode_t *p_entnode; _CDIO_LIST_FOREACH (p_entnode, p_stat_list) { iso9660_stat_t *p_statbuf = (iso9660_stat_t *) _cdio_list_node_data (p_entnode); stat_vector.push_back(new ISO9660::Stat(p_statbuf)); } _cdio_list_free (p_stat_list, false); return true; } else {
static iso9660_stat_t * find_fs_lsn_recurse (CdIo_t *p_cdio, const char pathname[], lsn_t lsn) { CdioList_t *entlist = iso9660_fs_readdir (p_cdio, pathname, true); CdioList_t *dirlist = _cdio_list_new (); CdioListNode_t *entnode; cdio_assert (entlist != NULL); /* iterate over each entry in the directory */ _CDIO_LIST_FOREACH (entnode, entlist) { iso9660_stat_t *statbuf = _cdio_list_node_data (entnode); char _fullname[4096] = { 0, }; char *filename = (char *) statbuf->filename; snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, filename); strncat (_fullname, "/", sizeof (_fullname)); if (statbuf->type == _STAT_DIR && strcmp ((char *) statbuf->filename, ".") && strcmp ((char *) statbuf->filename, "..")) _cdio_list_append (dirlist, strdup (_fullname)); if (statbuf->lsn == lsn) { unsigned int len=sizeof(iso9660_stat_t)+strlen(statbuf->filename)+1; iso9660_stat_t *ret_stat = _cdio_malloc(len); memcpy(ret_stat, statbuf, len); _cdio_list_free (entlist, true); _cdio_list_free (dirlist, true); return ret_stat; } }
static bool find_fs_lsn_recurse (const CdIo *cdio, const char pathname[], /*out*/ iso9660_stat_t *statbuf, lsn_t lsn) { CdioList *entlist = iso9660_fs_readdir (cdio, pathname, true); CdioList *dirlist = _cdio_list_new (); CdioListNode *entnode; cdio_assert (entlist != NULL); /* iterate over each entry in the directory */ _CDIO_LIST_FOREACH (entnode, entlist) { char *name = _cdio_list_node_data (entnode); char _fullname[4096] = { 0, }; snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, name); if (iso9660_fs_stat (cdio, _fullname, statbuf, true)) cdio_assert_not_reached (); strncat (_fullname, "/", sizeof (_fullname)); if (statbuf->type == _STAT_DIR && strcmp (name, ".") && strcmp (name, "..")) _cdio_list_append (dirlist, strdup (_fullname)); if (statbuf->lsn == lsn) { _cdio_list_free (entlist, true); _cdio_list_free (dirlist, true); return true; } }
static void print_iso9660_recurse (CdIo_t *p_cdio, const char pathname[], cdio_fs_anal_t fs, bool b_mode2) { CdioList_t *entlist; CdioList_t *dirlist = _cdio_list_new (); CdioListNode_t *entnode; uint8_t i_joliet_level; i_joliet_level = (opts.no_joliet) ? 0 : cdio_get_joliet_level(p_cdio); entlist = iso9660_fs_readdir (p_cdio, pathname, b_mode2); sprintf (temp_msg, "%s:\n", pathname); report(stdout, temp_msg); if (NULL == entlist) { report( stderr, "Error getting above directory information\n" ); return; } /* Iterate over files in this directory */ _CDIO_LIST_FOREACH (entnode, entlist) { iso9660_stat_t *statbuf = _cdio_list_node_data (entnode); char *iso_name = statbuf->filename; char _fullname[4096] = { 0, }; char translated_name[MAX_ISONAME+1]; #define DATESTR_SIZE 30 char date_str[DATESTR_SIZE]; iso9660_name_translate_ext(iso_name, translated_name, i_joliet_level); snprintf (_fullname, sizeof (_fullname), "%s%s", pathname, iso_name); strncat (_fullname, "/", sizeof (_fullname)); if (statbuf->type == _STAT_DIR && strcmp (iso_name, ".") && strcmp (iso_name, "..")) _cdio_list_append (dirlist, strdup (_fullname)); if (fs & CDIO_FS_ANAL_XA) { sprintf (temp_msg, " %c %s %d %d [fn %.2d] [LSN %6lu] ", (statbuf->type == _STAT_DIR) ? 'd' : '-', iso9660_get_xa_attr_str (statbuf->xa.attributes), uint16_from_be (statbuf->xa.user_id), uint16_from_be (statbuf->xa.group_id), statbuf->xa.filenum, (long unsigned int) statbuf->lsn); report(stdout, temp_msg); if (uint16_from_be(statbuf->xa.attributes) & XA_ATTR_MODE2FORM2) { sprintf (temp_msg, "%9u (%9u)", (unsigned int) statbuf->secsize * M2F2_SECTOR_SIZE, (unsigned int) statbuf->size); report(stdout, temp_msg); } else { printf ("%9u", (unsigned int) statbuf->size); } } strftime(date_str, DATESTR_SIZE, "%b %d %Y %H:%M ", &statbuf->tm); sprintf (temp_msg, " %s %s\n", date_str, translated_name); report(stdout, temp_msg); }