Skip to content

Commit 580c5b3

Browse files
committed
kconfig: make parent directories for the saved .config as needed
With menuconfig / nconfig, users can input any file path from the "Save" menu, but it fails if the parent directory does not exist. Why not create the parent directory automatically. I think this is a user-friendly behavior. I changed the error messages in menuconfig / nconfig. "Nonexistent directory" is no longer the most likely reason of the failure. Perhaps, the user specified the existing directory, or attempted to write to the location without write permission. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 67424f6 commit 580c5b3

File tree

3 files changed

+5
-3
lines changed

3 files changed

+5
-3
lines changed

scripts/kconfig/confdata.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -881,6 +881,9 @@ int conf_write(const char *name)
881881
return -1;
882882
}
883883

884+
if (make_parent_dir(name))
885+
return -1;
886+
884887
env = getenv("KCONFIG_OVERWRITECONFIG");
885888
if (env && *env) {
886889
*tmpname = 0;

scripts/kconfig/mconf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -936,7 +936,7 @@ static void conf_save(void)
936936
set_config_filename(dialog_input_result);
937937
return;
938938
}
939-
show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60);
939+
show_textbox(NULL, "Can't create file!", 5, 60);
940940
break;
941941
case 1:
942942
show_helptext("Save Alternate Configuration", save_config_help);

scripts/kconfig/nconf.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,8 +1438,7 @@ static void conf_save(void)
14381438
set_config_filename(dialog_input_result);
14391439
return;
14401440
}
1441-
btn_dialog(main_window, "Can't create file! "
1442-
"Probably a nonexistent directory.",
1441+
btn_dialog(main_window, "Can't create file!",
14431442
1, "<OK>");
14441443
break;
14451444
case 1:

0 commit comments

Comments
 (0)