[cmd] fix the use of relative paths with option -i

* Closes #2232
This commit is contained in:
Pete Batard 2023-04-23 13:06:32 +01:00
parent 3177e70e25
commit a354178239
No known key found for this signature in database
GPG key ID: 38E0CF5E69EDD671
2 changed files with 16 additions and 11 deletions

View file

@ -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])) {