Skip to content

Commit

Permalink
kconfig: make parent directories for the saved .config as needed
Browse files Browse the repository at this point in the history
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 <yamada.masahiro@socionext.com>
  • Loading branch information
Masahiro Yamada committed May 10, 2019
1 parent 67424f6 commit 580c5b3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
3 changes: 3 additions & 0 deletions scripts/kconfig/confdata.c
Original file line number Diff line number Diff line change
Expand Up @@ -881,6 +881,9 @@ int conf_write(const char *name)
return -1;
}

if (make_parent_dir(name))
return -1;

env = getenv("KCONFIG_OVERWRITECONFIG");
if (env && *env) {
*tmpname = 0;
Expand Down
2 changes: 1 addition & 1 deletion scripts/kconfig/mconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,7 @@ static void conf_save(void)
set_config_filename(dialog_input_result);
return;
}
show_textbox(NULL, "Can't create file! Probably a nonexistent directory.", 5, 60);
show_textbox(NULL, "Can't create file!", 5, 60);
break;
case 1:
show_helptext("Save Alternate Configuration", save_config_help);
Expand Down
3 changes: 1 addition & 2 deletions scripts/kconfig/nconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1438,8 +1438,7 @@ static void conf_save(void)
set_config_filename(dialog_input_result);
return;
}
btn_dialog(main_window, "Can't create file! "
"Probably a nonexistent directory.",
btn_dialog(main_window, "Can't create file!",
1, "<OK>");
break;
case 1:
Expand Down

0 comments on commit 580c5b3

Please sign in to comment.