summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristophe Grenier <grenier@cgsecurity.org>2014-03-21 08:44:24 +0100
committerChristophe Grenier <grenier@cgsecurity.org>2014-03-21 08:44:24 +0100
commit3012b0fc1906a65ac2d41f67855ddb0e8a5e9422 (patch)
tree234404faf6a2b57334fad33b3eabeccb8742747a /src
parent916d3746c7249bb1c795160d5966742ec1b3bad7 (diff)
src/qmainrec.cpp: Simplify the code starting PhotoRec when DISPLAY is not set.
Diffstat (limited to 'src')
-rw-r--r--src/qmainrec.cpp29
1 files changed, 7 insertions, 22 deletions
diff --git a/src/qmainrec.cpp b/src/qmainrec.cpp
index f8da1d8..23df756 100644
--- a/src/qmainrec.cpp
+++ b/src/qmainrec.cpp
@@ -48,27 +48,6 @@
#include "file_jpg.h"
#include "ntfs_dir.h"
-#ifdef Q_WS_X11
-static void run_photorec(int argc, char **argv)
-{
- int i;
- char **argv2;
- argv2 = (char **)MALLOC(sizeof(char *) * (argc + 2));
- argv2[0]=strdup("photorec");
- for (i=0; i < argc; i++)
- argv2[i+1] = argv[i];
- argv2[i+1]=NULL;
- printf("DISPLAY variable not set. Switching to PhotoRec in text mode.\n");
- fflush(stdout);
- if(execv(argv2[0], argv2)<0)
- {
- printf("photorec failed: %s\n", strerror(errno));
- }
- free(argv2[0]);
- free(argv2);
-}
-#endif
-
int main(int argc, char *argv[])
{
int log_errno=0;
@@ -76,7 +55,13 @@ int main(int argc, char *argv[])
FILE *log_handle;
#ifdef Q_WS_X11
if(getenv("DISPLAY")==NULL)
- run_photorec(argc, argv);
+ {
+ printf("DISPLAY variable not set. Switching to PhotoRec in text mode.\n");
+ if(execv("photorec", argv)<0)
+ {
+ printf("photorec failed: %s\n", strerror(errno));
+ }
+ }
#endif
QApplication a(argc, argv);
log_handle=log_open("qphotorec.log", TD_LOG_CREATE, &log_errno);