From a354178239569d48a91b44278c7a66b6514dec0d Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Sun, 23 Apr 2023 13:06:32 +0100 Subject: [PATCH] [cmd] fix the use of relative paths with option -i * Closes #2232 --- src/rufus.c | 17 +++++++++++------ src/rufus.rc | 10 +++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/rufus.c b/src/rufus.c index 007817be..61f3d87e 100755 --- a/src/rufus.c +++ b/src/rufus.c @@ -3498,14 +3498,19 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine // No need to reprocess that option break; case 'i': - if (_access(optarg, 0) != -1) { + safe_free(image_path); + image_path = calloc(1, MAX_PATH); + if (image_path == NULL) + break; + IGNORE_RETVAL(_chdirU(app_dir)); + IGNORE_RETVAL(GetFullPathNameU(optarg, MAX_PATH, image_path, NULL)); + // FILE_ATTRIBUTE_DIRECTORY is set for both dir and access error + if (GetFileAttributesU(image_path) & FILE_ATTRIBUTE_DIRECTORY) { + printf("Could not find image '%s'\n", image_path); safe_free(image_path); - image_path = safe_strdup(optarg); - img_provided = TRUE; - } - else { - printf("Could not find ISO image '%s'\n", optarg); + break; } + img_provided = TRUE; break; case 'l': if (isdigitU(optarg[0])) { diff --git a/src/rufus.rc b/src/rufus.rc index 2b6f6eda..76fc0601 100644 --- a/src/rufus.rc +++ b/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 4.0.2029" +CAPTION "Rufus 4.0.2030" FONT 9, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP @@ -392,8 +392,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 4,0,2029,0 - PRODUCTVERSION 4,0,2029,0 + FILEVERSION 4,0,2030,0 + PRODUCTVERSION 4,0,2030,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -411,13 +411,13 @@ BEGIN VALUE "Comments", "https://rufus.ie" VALUE "CompanyName", "Akeo Consulting" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "4.0.2029" + VALUE "FileVersion", "4.0.2030" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2023 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html" VALUE "OriginalFilename", "rufus-4.0.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "4.0.2029" + VALUE "ProductVersion", "4.0.2030" END END BLOCK "VarFileInfo"