summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2019-12-10 20:57:57 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2019-12-10 20:57:57 +0100
commitac95883e2216cae52285b72dbdda9d443f9894ea (patch)
treeb0c536dcd23395f3577c267fb51e126c6293f93a
parent8a91bdfbfd5dc9124ad5fb1a7beda5a8ebcf5b97 (diff)
"photorec /d recup_dir /cmd resume" can be used to resume a session
automatically. If no session is available, prompt the user. See https://github.com/cgsecurity/testdisk/issues/73
-rw-r--r--src/pdiskseln.c5
-rw-r--r--src/phmain.c4
2 files changed, 7 insertions, 2 deletions
diff --git a/src/pdiskseln.c b/src/pdiskseln.c
index c00d65a..9779c8c 100644
--- a/src/pdiskseln.c
+++ b/src/pdiskseln.c
@@ -267,14 +267,15 @@ int do_curses_photorec(struct ph_param *params, struct ph_options *options, cons
static alloc_data_t list_search_space={
.list = TD_LIST_HEAD_INIT(list_search_space.list)
};
- if(params->cmd_device==NULL)
+ const int resume_session=(params->cmd_device!=NULL && strcmp(params->cmd_device,"resume")==0);
+ if(params->cmd_device==NULL || resume_session!=0)
{
char *saved_device=NULL;
char *saved_cmd=NULL;
session_load(&saved_device, &saved_cmd,&list_search_space);
if(saved_device!=NULL && saved_cmd!=NULL && !td_list_empty(&list_search_space.list)
#ifdef HAVE_NCURSES
- && ask_confirmation("Continue previous session ? (Y/N)")!=0
+ && ( resume_session!=0 || ask_confirmation("Continue previous session ? (Y/N)")!=0)
#endif
)
{
diff --git a/src/phmain.c b/src/phmain.c
index 2205ceb..cbba88e 100644
--- a/src/phmain.c
+++ b/src/phmain.c
@@ -245,6 +245,10 @@ int main( int argc, char **argv )
}
else if((strcmp(argv[i],"/nosetlocale")==0) || (strcmp(argv[i],"-nosetlocale")==0))
run_setlocale=0;
+ else if(i+1 <= argc && strcmp(argv[i],"/cmd")==0 && strcmp(argv[i+1],"resume")==0)
+ {
+ params.cmd_device=argv[++i];
+ }
else if(strcmp(argv[i],"/cmd")==0)
{
if(i+2>=argc)