mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[misc] improve/factorize '/' ↔ '\' conversions
This commit is contained in:
parent
14f19e5275
commit
2b7b81808f
3 changed files with 21 additions and 27 deletions
32
src/iso.c
32
src/iso.c
|
@ -328,15 +328,14 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t file_length, const
|
|||
static void fix_config(const char* psz_fullpath, const char* psz_path, const char* psz_basename, EXTRACT_PROPS* props)
|
||||
{
|
||||
BOOL modified = FALSE;
|
||||
size_t i, nul_pos;
|
||||
size_t nul_pos;
|
||||
char *iso_label = NULL, *usb_label = NULL, *src, *dst;
|
||||
|
||||
nul_pos = safe_strlen(psz_fullpath);
|
||||
src = safe_strdup(psz_fullpath);
|
||||
if (src == NULL)
|
||||
return;
|
||||
for (i=0; i<nul_pos; i++)
|
||||
if (src[i] == '/') src[i] = '\\';
|
||||
nul_pos = strlen(src);
|
||||
to_windows_path(src);
|
||||
|
||||
// Add persistence to the kernel options
|
||||
if ((boot_type == BT_IMAGE) && HAS_PERSISTENCE(img_report) && persistence_size) {
|
||||
|
@ -437,25 +436,21 @@ static void fix_config(const char* psz_fullpath, const char* psz_path, const cha
|
|||
|
||||
static void print_extracted_file(char* psz_fullpath, uint64_t file_length)
|
||||
{
|
||||
size_t i, nul_pos;
|
||||
size_t nul_pos;
|
||||
|
||||
if (psz_fullpath == NULL)
|
||||
return;
|
||||
// Replace slashes with backslashes and append the size to the path for UI display
|
||||
to_windows_path(psz_fullpath);
|
||||
nul_pos = strlen(psz_fullpath);
|
||||
for (i = 0; i < nul_pos; i++)
|
||||
if (psz_fullpath[i] == '/')
|
||||
psz_fullpath[i] = '\\';
|
||||
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(file_length, TRUE, FALSE));
|
||||
uprintf("Extracting: %s\n", psz_fullpath);
|
||||
safe_sprintf(&psz_fullpath[nul_pos], 24, " (%s)", SizeToHumanReadable(file_length, FALSE, FALSE));
|
||||
PrintStatus(0, MSG_000, psz_fullpath); // MSG_000 is "%s"
|
||||
// ISO9660 cannot handle backslashes
|
||||
for (i = 0; i < nul_pos; i++)
|
||||
if (psz_fullpath[i] == '\\')
|
||||
psz_fullpath[i] = '/';
|
||||
// Remove the appended size for extraction
|
||||
psz_fullpath[nul_pos] = 0;
|
||||
// ISO9660 cannot handle backslashes
|
||||
to_unix_path(psz_fullpath);
|
||||
}
|
||||
|
||||
static void alt_print_extracted_file(const char* psz_fullpath, uint64_t file_length)
|
||||
|
@ -1255,13 +1250,9 @@ out:
|
|||
static_sprintf(path, "%s/%s", isolinux_dir, efi_cfg_name[i]);
|
||||
fprintf(fd, "DEFAULT loadconfig\n\nLABEL loadconfig\n CONFIG %s\n APPEND %s\n", &path[2], &isolinux_dir[2]);
|
||||
fclose(fd);
|
||||
for (j = 0; j < len; j++)
|
||||
if (symlinked_syslinux[j] == '/')
|
||||
symlinked_syslinux[j] = '\\';
|
||||
to_windows_path(symlinked_syslinux);
|
||||
uprintf("Created: %s\\%s → %s", symlinked_syslinux, efi_cfg_name[i], &path[2]);
|
||||
for (j = 0; j < len; j++)
|
||||
if (symlinked_syslinux[j] == '\\')
|
||||
symlinked_syslinux[j] = '/';
|
||||
to_unix_path(symlinked_syslinux);
|
||||
fd = NULL;
|
||||
}
|
||||
}
|
||||
|
@ -1390,7 +1381,7 @@ out:
|
|||
|
||||
uint32_t GetInstallWimVersion(const char* iso)
|
||||
{
|
||||
char *wim_path = NULL, *p, buf[UDF_BLOCKSIZE] = { 0 };
|
||||
char *wim_path = NULL, buf[UDF_BLOCKSIZE] = { 0 };
|
||||
uint32_t* wim_header = (uint32_t*)buf, r = 0xffffffff;
|
||||
iso9660_t* p_iso = NULL;
|
||||
udf_t* p_udf = NULL;
|
||||
|
@ -1402,8 +1393,7 @@ uint32_t GetInstallWimVersion(const char* iso)
|
|||
goto out;
|
||||
// UDF indiscriminately accepts slash or backslash delimiters,
|
||||
// but ISO-9660 requires slash
|
||||
for (p = wim_path; *p != 0; p++)
|
||||
if (*p == '\\') *p = '/';
|
||||
to_unix_path(wim_path);
|
||||
|
||||
// First try to open as UDF - fallback to ISO if it failed
|
||||
p_udf = udf_open(iso);
|
||||
|
|
|
@ -160,12 +160,16 @@
|
|||
#define safe_atoi(str) ((((char*)(str))==NULL)?0:atoi(str))
|
||||
#define safe_strlen(str) ((((char*)(str))==NULL)?0:strlen(str))
|
||||
#define safe_strdup _strdup
|
||||
#define to_windows_path(str) do { size_t __i; for (__i = 0; __i < safe_strlen(str); __i++) if (str[__i] == '/') str[__i] = '\\'; } while(0)
|
||||
#if defined(_MSC_VER)
|
||||
#define safe_vsnprintf(buf, size, format, arg) _vsnprintf_s(buf, size, _TRUNCATE, format, arg)
|
||||
#else
|
||||
#define safe_vsnprintf vsnprintf
|
||||
#endif
|
||||
static __inline void static_repchr(char* p, char s, char r) {
|
||||
if (p != NULL) while (*p != 0) { if (*p == s) *p = r; p++; }
|
||||
}
|
||||
#define to_unix_path(str) static_repchr(str, '\\', '/')
|
||||
#define to_windows_path(str) static_repchr(str, '/', '\\')
|
||||
|
||||
extern void _uprintf(const char *format, ...);
|
||||
extern void _uprintfs(const char *str);
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
|||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
EXSTYLE WS_EX_ACCEPTFILES
|
||||
CAPTION "Rufus 3.20.1917"
|
||||
CAPTION "Rufus 3.20.1918"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -395,8 +395,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 3,20,1917,0
|
||||
PRODUCTVERSION 3,20,1917,0
|
||||
FILEVERSION 3,20,1918,0
|
||||
PRODUCTVERSION 3,20,1918,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -414,13 +414,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "3.20.1917"
|
||||
VALUE "FileVersion", "3.20.1918"
|
||||
VALUE "InternalName", "Rufus"
|
||||
VALUE "LegalCopyright", "© 2011-2022 Pete Batard (GPL v3)"
|
||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||
VALUE "OriginalFilename", "rufus-3.20.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "3.20.1917"
|
||||
VALUE "ProductVersion", "3.20.1918"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue