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

[syslinux] fix missing syslinux.cfg creation

* Issue was introduced with 299506056a
* Also improve StrArray definition
This commit is contained in:
Pete Batard 2014-01-22 01:28:25 +00:00
parent 3ae7ec4af5
commit 3c2873bbdc
5 changed files with 35 additions and 36 deletions

View file

@ -580,17 +580,17 @@ out:
// If multiple config files exist, choose the one with the shortest path
// (so that a '/syslinux.cfg' is preferred over a '/isolinux/isolinux.cfg')
if (!IsStrArrayEmpty(config_path)) {
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[0]);
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[0]);
for (i=1; i<config_path.Index; i++) {
if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.Table[i]))
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.Table[i]);
if (safe_strlen(iso_report.cfg_path) > safe_strlen(config_path.String[i]))
safe_strcpy(iso_report.cfg_path, sizeof(iso_report.cfg_path), config_path.String[i]);
}
uprintf("Will use %s for Syslinux\n", iso_report.cfg_path);
// Extract all of the isolinux.bin files we found to identify their versions
for (i=0; i<isolinux_path.Index; i++) {
size = (size_t)ExtractISOFile(src_iso, isolinux_path.Table[i], dot_isolinux_bin);
size = (size_t)ExtractISOFile(src_iso, isolinux_path.String[i], dot_isolinux_bin);
if (size == 0) {
uprintf("Could not access %s\n", isolinux_path.Table[i]);
uprintf("Could not access %s\n", isolinux_path.String[i]);
} else {
buf = (char*)calloc(size, 1);
if (buf == NULL) break;
@ -610,8 +610,8 @@ out:
j = (int)i;
} else if (iso_report.sl_version != sl_version) {
uprintf("Found conflicting %s versions:\n '%s' (v%d.%02d) vs '%s' (v%d.%02d)\n", isolinux_bin,
isolinux_path.Table[j], SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version),
isolinux_path.Table[i], SL_MAJOR(sl_version), SL_MINOR(sl_version));
isolinux_path.String[j], SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version),
isolinux_path.String[i], SL_MAJOR(sl_version), SL_MINOR(sl_version));
}
break;
}
@ -624,7 +624,7 @@ out:
static_sprintf(iso_report.sl_version_str, "v%d.%02d",
SL_MAJOR(iso_report.sl_version), SL_MINOR(iso_report.sl_version));
uprintf("Detected Isolinux version: %s (from '%s')",
iso_report.sl_version_str, isolinux_path.Table[j]);
iso_report.sl_version_str, isolinux_path.String[j]);
if ( (has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) < 5))
|| (!has_ldlinux_c32 && (SL_MAJOR(iso_report.sl_version) >= 5)) )
uprintf("Warning: Conflict between Isolinux version and the presence of ldlinux.c32...\n");
@ -656,7 +656,7 @@ out:
}
StrArrayDestroy(&config_path);
StrArrayDestroy(&isolinux_path);
} else if (!IsStrArrayEmpty(config_path)) {
} else if (HAS_SYSLINUX(iso_report)) {
safe_sprintf(path, sizeof(path), "%s\\syslinux.cfg", dest_dir);
// Create a /syslinux.cfg (if none exists) that points to the existing isolinux cfg
fd = fopen(path, "r");

View file

@ -589,7 +589,7 @@ static BOOL PopulateProperties(int ComboIndex)
SetTargetSystem();
SetFSFromISO();
EnableBootOptions(TRUE);
device_tooltip = (char*) malloc(safe_strlen(DriveID.Table[ComboIndex]) + 16);
device_tooltip = (char*) malloc(safe_strlen(DriveID.String[ComboIndex]) + 16);
// Set a proposed label according to the size (eg: "256MB", "8GB")
if (HumanReadableSize < 1.0) {
@ -601,14 +601,14 @@ static BOOL PopulateProperties(int ComboIndex)
safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label),
"%0.0f%s", ceil(HumanReadableSize), lmprintf(MSG_020+i));
if (device_tooltip != NULL)
safe_sprintf(device_tooltip, safe_strlen(DriveID.Table[ComboIndex]) + 16,
"%s (%0.0f%s)", DriveID.Table[ComboIndex], ceil(HumanReadableSize), lmprintf(MSG_020+i));
safe_sprintf(device_tooltip, safe_strlen(DriveID.String[ComboIndex]) + 16,
"%s (%0.0f%s)", DriveID.String[ComboIndex], ceil(HumanReadableSize), lmprintf(MSG_020+i));
} else {
safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label),
"%0.2f%s", HumanReadableSize, lmprintf(MSG_020+i));
if (device_tooltip != NULL)
safe_sprintf(device_tooltip, safe_strlen(DriveID.Table[ComboIndex]) + 16,
"%s (%0.2f%s)", DriveID.Table[ComboIndex], HumanReadableSize, lmprintf(MSG_020+i));
safe_sprintf(device_tooltip, safe_strlen(DriveID.String[ComboIndex]) + 16,
"%s (%0.2f%s)", DriveID.String[ComboIndex], HumanReadableSize, lmprintf(MSG_020+i));
}
// Add a tooltip (with the size of the device in parenthesis)
@ -618,11 +618,11 @@ static BOOL PopulateProperties(int ComboIndex)
// If no existing label is available and no ISO is selected, propose one according to the size (eg: "256MB", "8GB")
if ((iso_path == NULL) || (iso_report.label[0] == 0)) {
if ( (safe_stricmp(no_label, DriveLabel.Table[ComboIndex]) == 0)
|| (safe_stricmp(lmprintf(MSG_207), DriveLabel.Table[ComboIndex]) == 0) ) {
if ( (safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0)
|| (safe_stricmp(lmprintf(MSG_207), DriveLabel.String[ComboIndex]) == 0) ) {
SetWindowTextU(hLabel, SelectedDrive.proposed_label);
} else {
SetWindowTextU(hLabel, DriveLabel.Table[ComboIndex]);
SetWindowTextU(hLabel, DriveLabel.String[ComboIndex]);
}
} else {
SetWindowTextU(hLabel, iso_report.label);

View file

@ -369,8 +369,7 @@ static __inline void *_reallocf(void *ptr, size_t size)
/* Basic String Array */
typedef struct {
// TODO: rename 'Table' to 'String'
char** Table;
char** String;
size_t Index; // Current array size
size_t Max; // Maximum array size
} StrArray;

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 329
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.4.3.387"
CAPTION "Rufus v1.4.3.388"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,291,50,14
@ -288,8 +288,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,3,387
PRODUCTVERSION 1,4,3,387
FILEVERSION 1,4,3,388
PRODUCTVERSION 1,4,3,388
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -306,13 +306,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.4.3.387"
VALUE "FileVersion", "1.4.3.388"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.4.3.387"
VALUE "ProductVersion", "1.4.3.388"
END
END
BLOCK "VarFileInfo"

View file

@ -1,7 +1,7 @@
/*
* Rufus: The Reliable USB Formatting Utility
* Standard Windows function calls
* Copyright © 2013 Pete Batard <pete@akeo.ie>
* Copyright © 2013-2014 Pete Batard <pete@akeo.ie>
*
* 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
@ -151,28 +151,28 @@ void StrArrayCreate(StrArray* arr, size_t initial_size)
{
if (arr == NULL) return;
arr->Max = initial_size; arr->Index = 0;
arr->Table = (char**)calloc(arr->Max, sizeof(char*));
if (arr->Table == NULL)
arr->String = (char**)calloc(arr->Max, sizeof(char*));
if (arr->String == NULL)
uprintf("Could not allocate string array\n");
}
void StrArrayAdd(StrArray* arr, const char* str)
{
char** old_table;
if ((arr == NULL) || (arr->Table == NULL))
if ((arr == NULL) || (arr->String == NULL))
return;
if (arr->Index == arr->Max) {
arr->Max *= 2;
old_table = arr->Table;
arr->Table = (char**)realloc(arr->Table, arr->Max*sizeof(char*));
if (arr->Table == NULL) {
old_table = arr->String;
arr->String = (char**)realloc(arr->String, arr->Max*sizeof(char*));
if (arr->String == NULL) {
free(old_table);
uprintf("Could not reallocate string array\n");
return;
}
}
arr->Table[arr->Index] = safe_strdup(str);
if (arr->Table[arr->Index++] == NULL) {
arr->String[arr->Index] = safe_strdup(str);
if (arr->String[arr->Index++] == NULL) {
uprintf("Could not store string in array\n");
}
}
@ -180,10 +180,10 @@ void StrArrayAdd(StrArray* arr, const char* str)
void StrArrayClear(StrArray* arr)
{
size_t i;
if ((arr == NULL) || (arr->Table == NULL))
if ((arr == NULL) || (arr->String == NULL))
return;
for (i=0; i<arr->Index; i++) {
safe_free(arr->Table[i]);
safe_free(arr->String[i]);
}
arr->Index = 0;
}
@ -192,7 +192,7 @@ void StrArrayDestroy(StrArray* arr)
{
StrArrayClear(arr);
if (arr != NULL)
safe_free(arr->Table);
safe_free(arr->String);
}
/*