1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[iso] improvements to iso recursive listing

* ISO9660 directory recursion
* use default log handler
* also use warn instead of error in udf_fs.c
This commit is contained in:
Pete Batard 2012-01-18 00:52:12 +00:00
parent fcc2486867
commit 7fbcccdc65
4 changed files with 49 additions and 51 deletions

View file

@ -5,14 +5,6 @@
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter> </Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\iso.c"> <ClCompile Include="..\iso.c">

View file

@ -50,12 +50,7 @@
CdIo_t* cdio_open (const char *psz_source, driver_id_t driver_id) {return NULL;} CdIo_t* cdio_open (const char *psz_source, driver_id_t driver_id) {return NULL;}
void cdio_destroy (CdIo_t *p_cdio) {} void cdio_destroy (CdIo_t *p_cdio) {}
static void log_handler(cdio_log_level_t level, const char* message) static void udf_print_file_info(const udf_dirent_t *p_udf_dirent, const char* psz_dirname)
{
uprintf("cdio %d message: %s\n", level, message);
}
static void print_file_info(const udf_dirent_t *p_udf_dirent, const char* psz_dirname)
{ {
time_t mod_time = udf_get_modification_time(p_udf_dirent); time_t mod_time = udf_get_modification_time(p_udf_dirent);
char psz_mode[11] = "invalid"; char psz_mode[11] = "invalid";
@ -67,11 +62,11 @@ static void print_file_info(const udf_dirent_t *p_udf_dirent, const char* psz_di
(*psz_fname?psz_fname:"/"), ctime(&mod_time)); (*psz_fname?psz_fname:"/"), ctime(&mod_time));
} }
static void list_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *psz_path) static void udf_list_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *psz_path)
{ {
if (!p_udf_dirent) if (!p_udf_dirent)
return; return;
print_file_info(p_udf_dirent, psz_path); udf_print_file_info(p_udf_dirent, psz_path);
while (udf_readdir(p_udf_dirent)) { while (udf_readdir(p_udf_dirent)) {
if (udf_is_dir(p_udf_dirent)) { if (udf_is_dir(p_udf_dirent)) {
udf_dirent_t *p_udf_dirent2 = udf_opendir(p_udf_dirent); udf_dirent_t *p_udf_dirent2 = udf_opendir(p_udf_dirent);
@ -80,31 +75,55 @@ static void list_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *psz
const unsigned int i_newlen = 2 + strlen(psz_path) + strlen(psz_dirname); const unsigned int i_newlen = 2 + strlen(psz_path) + strlen(psz_dirname);
char* psz_newpath = (char*)calloc(sizeof(char), i_newlen); char* psz_newpath = (char*)calloc(sizeof(char), i_newlen);
_snprintf(psz_newpath, i_newlen, "%s%s/", psz_path, psz_dirname); _snprintf(psz_newpath, i_newlen, "%s%s/", psz_path, psz_dirname);
list_files(p_udf, p_udf_dirent2, psz_newpath); udf_list_files(p_udf, p_udf_dirent2, psz_newpath);
free(psz_newpath); free(psz_newpath);
} }
} else { } else {
print_file_info(p_udf_dirent, NULL); udf_print_file_info(p_udf_dirent, NULL);
} }
} }
} }
static void iso_list_files(iso9660_t* p_iso, const char *psz_path)
{
int i = 0;
char filename[4096], *p;
CdioListNode_t* p_entnode;
iso9660_stat_t *p_statbuf;
CdioList_t* p_entlist;
strncpy(filename, psz_path, 4094);
p = &filename[strlen(psz_path)];
*p++ = '/';
*p = 0;
p_entlist = iso9660_ifs_readdir(p_iso, psz_path);
if (!p_entlist)
return;
_CDIO_LIST_FOREACH (p_entnode, p_entlist) {
p_statbuf = (iso9660_stat_t*) _cdio_list_node_data(p_entnode);
if (i++ < 2)
continue; // Eliminate . and .. entries
iso9660_name_translate(p_statbuf->filename, p);
uprintf("%s [LSN %6d] %8u %s\n", (p_statbuf->type == _STAT_DIR)?"d":"-",
p_statbuf->lsn, p_statbuf->size, filename);
if (p_statbuf->type == _STAT_DIR)
iso_list_files(p_iso, filename);
}
_cdio_list_free(p_entlist, true);
}
BOOL ExtractISO(const char* src_iso, const char* dest_dir) BOOL ExtractISO(const char* src_iso, const char* dest_dir)
{ {
BOOL r = FALSE; BOOL r = FALSE;
CdioList_t* p_entlist;
CdioListNode_t* p_entnode;
iso9660_t* p_iso = NULL; iso9660_t* p_iso = NULL;
udf_t* p_udf = NULL; udf_t* p_udf = NULL;
udf_dirent_t* p_udf_root; udf_dirent_t* p_udf_root;
// udf_dirent_t* p_udf_file = NULL; // udf_dirent_t* p_udf_file = NULL;
const char *psz_path="/";
char *psz_str = NULL; char *psz_str = NULL;
char vol_id[UDF_VOLID_SIZE] = ""; char vol_id[UDF_VOLID_SIZE] = "";
char volset_id[UDF_VOLSET_ID_SIZE+1] = ""; char volset_id[UDF_VOLSET_ID_SIZE+1] = "";
cdio_log_set_handler(log_handler); cdio_loglevel_default = CDIO_LOG_DEBUG;
p_udf = udf_open(src_iso); p_udf = udf_open(src_iso);
if (p_udf == NULL) { if (p_udf == NULL) {
uprintf("Unable to open UDF image '%s'.\n", src_iso); uprintf("Unable to open UDF image '%s'.\n", src_iso);
@ -123,7 +142,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir)
uprintf("volume set id: %s\n", volset_id); uprintf("volume set id: %s\n", volset_id);
} }
uprintf("partition number: %d\n", udf_get_part_number(p_udf)); uprintf("partition number: %d\n", udf_get_part_number(p_udf));
list_files(p_udf, p_udf_root, ""); udf_list_files(p_udf, p_udf_root, "");
r = TRUE; r = TRUE;
goto out; goto out;
@ -143,21 +162,7 @@ try_iso:
print_vd_info("Volume ", iso9660_ifs_get_volume_id); print_vd_info("Volume ", iso9660_ifs_get_volume_id);
print_vd_info("Volume Set ", iso9660_ifs_get_volumeset_id); print_vd_info("Volume Set ", iso9660_ifs_get_volumeset_id);
p_entlist = iso9660_ifs_readdir(p_iso, psz_path); iso_list_files(p_iso, "");
/* 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);
uprintf("%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);
} else {
uprintf("Could not open ISO directory!\n");
}
r = TRUE; r = TRUE;
#if 0 #if 0
@ -220,15 +225,16 @@ out:
#ifdef ISO_TEST #ifdef ISO_TEST
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
// ExtractISO("D:\\src\\libcdio\\test\\udf102.iso", NULL); // ExtractISO("D:\\Incoming\\GRMSDKX_EN_DVD.iso", NULL);
ExtractISO("D:\\Incoming\\en_windows_7_ultimate_with_sp1_x64_dvd_618240.iso", NULL); ExtractISO("D:\\fd11src.iso", NULL);
// ExtractISO("D:\\Incoming\\en_windows_7_ultimate_with_sp1_x64_dvd_618240.iso", NULL);
while(getchar() != 0x0a); // ExtractISO("D:\\Incoming\\Windows 8 Preview\\WindowsDeveloperPreview-64bit-English-Developer.iso", NULL);
#ifdef _CRTDBG_MAP_ALLOC #ifdef _CRTDBG_MAP_ALLOC
_CrtDumpMemoryLeaks(); _CrtDumpMemoryLeaks();
#endif #endif
while(getchar() != 0x0a);
exit(0); exit(0);
} }
#endif #endif

View file

@ -678,11 +678,11 @@ udf_readdir(udf_dirent_t *p_udf_dirent)
that doesn't match the one we used when allocating the structure. If they are bigger that doesn't match the one we used when allocating the structure. If they are bigger
memcpy will result in memory overflow and corruption. Use min() as a workaround. */ memcpy will result in memory overflow and corruption. Use min() as a workaround. */
if ((p_udf_fe->i_alloc_descs != p_udf_dirent->fe.i_alloc_descs)) { if ((p_udf_fe->i_alloc_descs != p_udf_dirent->fe.i_alloc_descs)) {
cdio_error("MISMATCH! p_udf_dirent = %p: i_alloc_desc %d (new LBA) vs %d (existing)", p_udf_dirent, p_udf_fe->i_alloc_descs, p_udf_dirent->fe.i_alloc_descs); cdio_debug("MISMATCH! p_udf_dirent = %p: i_alloc_desc %d (new LBA) vs %d (existing)", p_udf_dirent, p_udf_fe->i_alloc_descs, p_udf_dirent->fe.i_alloc_descs);
i_alloc_descs = min(p_udf_fe->i_alloc_descs, p_udf_dirent->fe.i_alloc_descs); i_alloc_descs = min(p_udf_fe->i_alloc_descs, p_udf_dirent->fe.i_alloc_descs);
} }
if ((p_udf_fe->i_extended_attr != p_udf_dirent->fe.i_extended_attr)) { if ((p_udf_fe->i_extended_attr != p_udf_dirent->fe.i_extended_attr)) {
cdio_error("MISMATCH! p_udf_dirent = %p: i_extended_attr %d (new LBA) vs %d (existing)", p_udf_dirent, p_udf_fe->i_extended_attr, p_udf_dirent->fe.i_extended_attr); cdio_debug("MISMATCH! p_udf_dirent = %p: i_extended_attr %d (new LBA) vs %d (existing)", p_udf_dirent, p_udf_fe->i_extended_attr, p_udf_dirent->fe.i_extended_attr);
i_extended_attr = min(p_udf_fe->i_extended_attr, p_udf_dirent->fe.i_extended_attr); i_extended_attr = min(p_udf_fe->i_extended_attr, p_udf_dirent->fe.i_extended_attr);
} }

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 278 IDD_DIALOG DIALOGEX 12, 12, 206, 278
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.0.7.135" CAPTION "Rufus v1.0.7.136"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14 DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
@ -70,7 +70,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL, CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9 "SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.0.7 (Build 135)",IDC_STATIC,46,19,78,8 LTEXT "Version 1.0.7 (Build 136)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -208,8 +208,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,7,135 FILEVERSION 1,0,7,136
PRODUCTVERSION 1,0,7,135 PRODUCTVERSION 1,0,7,136
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -226,13 +226,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "akeo.ie" VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.0.7.135" VALUE "FileVersion", "1.0.7.136"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.0.7.135" VALUE "ProductVersion", "1.0.7.136"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"