From 26bdf36adb93789e7159577e53c9e426bb7a27cd Mon Sep 17 00:00:00 2001 From: Christophe Grenier Date: Sun, 19 May 2013 19:26:20 +0200 Subject: [PATCH] Fix windows compilation regression introduced in 1471f47a5c5b9d69863ec496bd7a57a9b0081d89 --- src/phrecn.c | 25 ------------------------- src/psearchn.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/phrecn.c b/src/phrecn.c index f5432d29..4f6b9136 100644 --- a/src/phrecn.c +++ b/src/phrecn.c @@ -88,31 +88,6 @@ extern file_check_list_t file_check_list; static int interface_cannot_create_file(void); -#if defined(__CYGWIN__) || defined(__MINGW32__) -/* Live antivirus protection may open file as soon as they are created by * - * PhotoRec. PhotoRec will not be able to overwrite a file as long as the * - * antivirus is scanning it, so let's wait a little bit if the creation * - * failed. */ - -#ifndef HAVE_SLEEP -#define sleep(x) Sleep((x)*1000) -#endif - -static FILE *fopen_with_retry(const char *path, const char *mode) -{ - FILE *handle; - if((handle=fopen(path, mode))!=NULL) - return handle; - sleep(1); - if((handle=fopen(path, mode))!=NULL) - return handle; - sleep(2); - if((handle=fopen(path, mode))!=NULL) - return handle; - return NULL; -} -#endif - #ifdef HAVE_NCURSES static void recovery_finished(disk_t *disk, const partition_t *partition, const unsigned int file_nbr, const char *recup_dir, const pstatus_t ind_stop) { diff --git a/src/psearchn.c b/src/psearchn.c index 6dfd93ef..0c1fd9b5 100644 --- a/src/psearchn.c +++ b/src/psearchn.c @@ -25,6 +25,9 @@ #endif #include +#ifdef HAVE_UNISTD_H +#include +#endif #ifdef HAVE_STDLIB_H #include #endif @@ -37,6 +40,13 @@ #ifdef HAVE_SYS_TIME_H #include #endif +#ifdef HAVE_WINDEF_H +#include +#endif +#ifdef HAVE_WINBASE_H +#include +#include +#endif #include "types.h" #include "common.h" #include "intrf.h" @@ -64,6 +74,39 @@ extern const file_hint_t file_hint_tar; extern const file_hint_t file_hint_dir; extern file_check_list_t file_check_list; +#if defined(__CYGWIN__) || defined(__MINGW32__) +/* Live antivirus protection may open file as soon as they are created by * + * PhotoRec. PhotoRec will not be able to overwrite a file as long as the * + * antivirus is scanning it, so let's wait a little bit if the creation * + * failed. */ + +#ifndef HAVE_SLEEP +#define sleep(x) Sleep((x)*1000) +#endif + +static FILE *fopen_with_retry(const char *path, const char *mode) +{ + FILE *handle; + if((handle=fopen(path, mode))!=NULL) + return handle; +#ifdef __MINGW32__ + Sleep(1000); +#else + sleep(1); +#endif + if((handle=fopen(path, mode))!=NULL) + return handle; +#ifdef __MINGW32__ + Sleep(2000); +#else + sleep(2); +#endif + if((handle=fopen(path, mode))!=NULL) + return handle; + return NULL; +} +#endif + pstatus_t photorec_aux(struct ph_param *params, const struct ph_options *options, alloc_data_t *list_search_space) { uint64_t offset;