mirror of https://github.com/pbatard/rufus.git
[iso] more testing, more fixup, more breakage
This commit is contained in:
parent
4565531201
commit
161130f7ea
109
src/iso.c
109
src/iso.c
|
@ -2,8 +2,8 @@
|
|||
* Rufus: The Reliable USB Formatting Utility
|
||||
* ISO file extraction
|
||||
* Copyright (c) 2011-2012 Pete Batard <pete@akeo.ie>
|
||||
* Based on libcdio's iso-read.c & iso-info.c:
|
||||
* Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
|
||||
* Based on libcdio's iso & udf samples:
|
||||
* Copyright (c) 2003-2011 Rocky Bernstein <rocky@gnu.org>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -19,13 +19,21 @@
|
|||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/* Memory leaks detection - define _CRTDBG_MAP_ALLOC as preprocessor macro */
|
||||
#ifdef _CRTDBG_MAP_ALLOC
|
||||
#include <stdlib.h>
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include "rufus.h"
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/logging.h>
|
||||
#include <cdio/iso9660.h>
|
||||
#include <cdio/udf.h>
|
||||
|
||||
#define print_vd_info(title, fn) \
|
||||
if (fn(p_iso, &psz_str)) { \
|
||||
|
@ -34,20 +42,98 @@
|
|||
free(psz_str); \
|
||||
psz_str = NULL;
|
||||
|
||||
/* Needed for UDF ISO access */
|
||||
CdIo_t* cdio_open (const char *psz_source, driver_id_t driver_id) {return NULL;}
|
||||
void cdio_destroy (CdIo_t *p_cdio) {}
|
||||
|
||||
static void log_handler(cdio_log_level_t level, const char* message)
|
||||
{
|
||||
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);
|
||||
char psz_mode[11] = "invalid";
|
||||
const char *psz_fname = psz_dirname?psz_dirname:udf_get_filename(p_udf_dirent);
|
||||
|
||||
/* Print directory attributes*/
|
||||
uprintf("%s %4d %lu %s %s\n", udf_mode_string(udf_get_posix_filemode(p_udf_dirent), psz_mode),
|
||||
udf_get_link_count(p_udf_dirent), (long unsigned int)udf_get_file_length(p_udf_dirent),
|
||||
(*psz_fname?psz_fname:"/"), ctime(&mod_time));
|
||||
}
|
||||
|
||||
static udf_dirent_t* list_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const char *psz_path)
|
||||
{
|
||||
if (!p_udf_dirent)
|
||||
return NULL;
|
||||
print_file_info(p_udf_dirent, psz_path);
|
||||
while (udf_readdir(p_udf_dirent)) {
|
||||
if (udf_is_dir(p_udf_dirent)) {
|
||||
udf_dirent_t *p_udf_dirent2 = udf_opendir(p_udf_dirent);
|
||||
if (p_udf_dirent2) {
|
||||
const char *psz_dirname = udf_get_filename(p_udf_dirent);
|
||||
const unsigned int i_newlen=2 + safe_strlen(psz_path) + safe_strlen(psz_dirname);
|
||||
char* psz_newpath = (char*)calloc(sizeof(char), i_newlen);
|
||||
safe_sprintf(psz_newpath, i_newlen, "%s%s/", psz_path, psz_dirname);
|
||||
uprintf("psz_newpath = %s\n", psz_newpath);
|
||||
list_files(p_udf, p_udf_dirent2, psz_newpath);
|
||||
free(psz_newpath);
|
||||
} else {
|
||||
uprintf("Could not open UDF directory!\n");
|
||||
}
|
||||
} else {
|
||||
print_file_info(p_udf_dirent, NULL);
|
||||
}
|
||||
}
|
||||
return p_udf_dirent;
|
||||
}
|
||||
|
||||
BOOL ExtractISO(const char* src_iso, const char* dest_dir)
|
||||
{
|
||||
BOOL r = FALSE;
|
||||
CdioList_t *p_entlist;
|
||||
CdioListNode_t *p_entnode;
|
||||
iso9660_t *p_iso;
|
||||
CdioList_t* p_entlist;
|
||||
CdioListNode_t* p_entnode;
|
||||
iso9660_t* p_iso = NULL;
|
||||
udf_t* p_udf = NULL;
|
||||
udf_dirent_t* p_udf_root;
|
||||
// udf_dirent_t* p_udf_file = NULL;
|
||||
const char *psz_path="/";
|
||||
char *psz_str = NULL;
|
||||
char vol_id[UDF_VOLID_SIZE] = "";
|
||||
char volset_id[UDF_VOLSET_ID_SIZE+1] = "";
|
||||
|
||||
cdio_log_set_handler(log_handler);
|
||||
|
||||
p_udf = udf_open(src_iso);
|
||||
if (p_udf == NULL) {
|
||||
uprintf("Unable to open UDF image '%s'.\n", src_iso);
|
||||
goto try_iso;
|
||||
}
|
||||
p_udf_root = udf_get_root(p_udf, true, 0);
|
||||
if (p_udf_root == NULL) {
|
||||
uprintf("Couldn't locate UDF root directory\n");
|
||||
goto out;
|
||||
}
|
||||
vol_id[0] = 0; volset_id[0] = 0;
|
||||
if (udf_get_volume_id(p_udf, vol_id, sizeof(vol_id)) > 0)
|
||||
uprintf("volume id: %s\n", vol_id);
|
||||
if (udf_get_volume_id(p_udf, volset_id, sizeof(volset_id)) >0 ) {
|
||||
volset_id[UDF_VOLSET_ID_SIZE]='\0';
|
||||
uprintf("volume set id: %s\n", volset_id);
|
||||
}
|
||||
uprintf("partition number: %d\n", udf_get_part_number(p_udf));
|
||||
list_files(p_udf, p_udf_root, "");
|
||||
udf_dirent_free(p_udf_root);
|
||||
|
||||
r = TRUE;
|
||||
goto out;
|
||||
|
||||
try_iso:
|
||||
p_iso = iso9660_open(src_iso);
|
||||
if (p_iso == NULL) {
|
||||
uprintf("Unable to open ISO image '%s'.\n", src_iso);
|
||||
goto out1;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Show basic CD info from the Primary Volume Descriptor. */
|
||||
|
@ -69,7 +155,9 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir)
|
|||
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);
|
||||
_cdio_list_free(p_entlist, true);
|
||||
} else {
|
||||
uprintf("Could not open ISO directory!\n");
|
||||
}
|
||||
r = TRUE;
|
||||
|
||||
|
@ -121,8 +209,11 @@ out3:
|
|||
fclose(outfd);
|
||||
out2:
|
||||
#endif
|
||||
iso9660_close(p_iso);
|
||||
out1:
|
||||
out:
|
||||
if (p_iso != NULL)
|
||||
iso9660_close(p_iso);
|
||||
if (p_udf != NULL)
|
||||
udf_close(p_udf);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -14,27 +14,15 @@
|
|||
#define EMPTY_ARRAY_SIZE
|
||||
#endif
|
||||
|
||||
/* Define 1 if you have BSDI-type CD-ROM support */
|
||||
#undef HAVE_BSDI_CDROM
|
||||
|
||||
/* Define to 1 if you have the `bzero' function. */
|
||||
#undef HAVE_BZERO
|
||||
|
||||
/* Define this if you have libcddb installed */
|
||||
#undef HAVE_CDDB
|
||||
|
||||
/* Define to 1 if you have the <CoreFoundation/CFBase.h> header file. */
|
||||
#undef HAVE_COREFOUNDATION_CFBASE_H
|
||||
|
||||
/* Define if time.h defines extern long timezone and int daylight vars. */
|
||||
#undef HAVE_DAYLIGHT
|
||||
|
||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||
#undef HAVE_DLFCN_H
|
||||
|
||||
/* Define to 1 if you have the <dvd.h> header file. */
|
||||
#undef HAVE_DVD_H
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#define HAVE_ERRNO_H 1
|
||||
|
||||
|
|
|
@ -152,9 +152,11 @@ typedef uint8_t ubyte;
|
|||
/* should work with most EDG-frontend based compilers */
|
||||
# define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
|
||||
# define PRAGMA_END_PACKED _Pragma("pack()")
|
||||
#elif defined(_MSC_VER)
|
||||
# define PRAGMA_BEGIN_PACKED __pragma(pack(push, 1))
|
||||
# define PRAGMA_END_PACKED __pragma(pack(pop))
|
||||
#else /* neither gcc nor _Pragma() available... */
|
||||
/* ...so let's be naive and hope the regression testsuite is run... */
|
||||
// TODO!
|
||||
# define PRAGMA_BEGIN_PACKED
|
||||
# define PRAGMA_END_PACKED
|
||||
#endif
|
||||
|
|
|
@ -480,7 +480,7 @@ udf_get_volumeset_id(udf_t *p_udf, /*out*/ uint8_t *volsetid,
|
|||
NULL is returned if the partition is not found or a root is not found or
|
||||
there is on error.
|
||||
|
||||
Caller must free result - use udf_file_free for that.
|
||||
Caller must free result - use udf_dirent_free for that.
|
||||
*/
|
||||
udf_dirent_t *
|
||||
udf_get_root (udf_t *p_udf, bool b_any_partition, partition_num_t i_partition)
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
#define IDC_PROGRESS 1012
|
||||
#define IDC_DOSTYPE 1013
|
||||
#define IDC_NBPASSES 1014
|
||||
#define IDC_TEST 1015
|
||||
#define IDC_ABOUT_LICENSE 1030
|
||||
#define IDC_ABOUT_ICON 1031
|
||||
#define IDC_RUFUS_BOLD 1032
|
||||
|
|
|
@ -1000,6 +1000,10 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
|||
case IDC_ABOUT:
|
||||
CreateAboutBox();
|
||||
break;
|
||||
case IDC_TEST:
|
||||
ExtractISO("D:\\fd11src.iso", NULL);
|
||||
// ExtractISO("D:\\Incoming\\en_windows_7_ultimate_with_sp1_x64_dvd_618240.iso", NULL);
|
||||
break;
|
||||
case IDC_DEVICE:
|
||||
switch (HIWORD(wParam)) {
|
||||
case CBN_SELCHANGE:
|
||||
|
|
|
@ -165,6 +165,7 @@ extern void DestroyTooltip(HWND hWnd);
|
|||
extern void DestroyAllTooltips(void);
|
||||
extern BOOL Notification(int type, char* title, char* format, ...);
|
||||
extern BOOL ExtractDOS(const char* path);
|
||||
extern BOOL ExtractISO(const char* src_iso, const char* dest_dir);
|
||||
extern BOOL InstallSyslinux(DWORD num, const char* drive_name);
|
||||
extern void __cdecl FormatThread(void* param);
|
||||
extern BOOL CreatePartition(HANDLE hDrive);
|
||||
|
|
13
src/rufus.rc
13
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 206, 278
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_APPWINDOW
|
||||
CAPTION "Rufus v1.0.7.125"
|
||||
CAPTION "Rufus v1.0.7.126"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Start",IDC_START,94,236,50,14
|
||||
|
@ -56,6 +56,7 @@ BEGIN
|
|||
CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,7,210,189,9
|
||||
COMBOBOX IDC_DOSTYPE,118,183,45,30,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_NBPASSES,118,159,45,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Test",IDC_TEST,62,236,20,14
|
||||
END
|
||||
|
||||
IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195
|
||||
|
@ -69,7 +70,7 @@ BEGIN
|
|||
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,
|
||||
"SysLink",WS_TABSTOP,46,47,114,9
|
||||
LTEXT "Version 1.0.7 (Build 125)",IDC_STATIC,46,19,78,8
|
||||
LTEXT "Version 1.0.7 (Build 126)",IDC_STATIC,46,19,78,8
|
||||
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
|
||||
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
||||
|
@ -207,8 +208,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 1,0,7,125
|
||||
PRODUCTVERSION 1,0,7,125
|
||||
FILEVERSION 1,0,7,126
|
||||
PRODUCTVERSION 1,0,7,126
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -225,13 +226,13 @@ BEGIN
|
|||
BEGIN
|
||||
VALUE "CompanyName", "akeo.ie"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "1.0.7.125"
|
||||
VALUE "FileVersion", "1.0.7.126"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
|
||||
VALUE "OriginalFilename", "rufus.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "1.0.7.125"
|
||||
VALUE "ProductVersion", "1.0.7.126"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in New Issue