summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/fidentify.c4
-rw-r--r--src/file_ace.c12
-rw-r--r--src/file_axx.c4
-rw-r--r--src/file_doc.c38
-rw-r--r--src/file_gif.c7
-rw-r--r--src/file_gpg.c14
-rw-r--r--src/file_hdf.c7
-rw-r--r--src/file_indd.c4
-rw-r--r--src/file_jpg.c20
-rw-r--r--src/file_m2ts.c14
-rw-r--r--src/file_mid.c11
-rw-r--r--src/file_mig.c4
-rw-r--r--src/file_mlv.c8
-rw-r--r--src/file_nk2.c11
-rw-r--r--src/file_par2.c4
-rw-r--r--src/file_pdf.c16
-rw-r--r--src/file_png.c7
-rw-r--r--src/file_riff.c8
-rw-r--r--src/file_spf.c4
-rw-r--r--src/file_tib.c14
-rw-r--r--src/file_zip.c50
-rw-r--r--src/filegen.c12
-rw-r--r--src/phbf.c4
-rw-r--r--src/photorec.c10
24 files changed, 271 insertions, 16 deletions
diff --git a/src/fidentify.c b/src/fidentify.c
index 3fadf8b..41f17e2 100644
--- a/src/fidentify.c
+++ b/src/fidentify.c
@@ -113,7 +113,11 @@ static int file_identify(const char *filename, const unsigned int check)
if(check > 0 && file_recovery_new.file_check!=NULL)
{
file_recovery_new.handle=file;
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery_new.handle, 0, SEEK_END);
+#else
fseek(file_recovery_new.handle, 0, SEEK_END);
+#endif
#ifdef HAVE_FTELLO
file_recovery_new.file_size=ftello(file_recovery_new.handle);
#else
diff --git a/src/file_ace.c b/src/file_ace.c
index 7cfa8fa..656860f 100644
--- a/src/file_ace.c
+++ b/src/file_ace.c
@@ -65,7 +65,11 @@ static void file_check_ace(file_recovery_t *file_recovery)
file_recovery->offset_error = 0;
file_recovery->offset_ok = 0;
file_recovery->file_size = 0;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, 0, SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle, 0, SEEK_SET)<0)
+#endif
return ;
#ifdef DEBUG_ACE
log_trace("file_check_ace\n");
@@ -84,7 +88,11 @@ static void file_check_ace(file_recovery_t *file_recovery)
file_recovery->file_size=0;
return ;
}
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, -sizeof(h)+4, SEEK_CUR)<0)
+#else
if(fseek(file_recovery->handle, -sizeof(h)+4, SEEK_CUR)<0)
+#endif
{
file_recovery->offset_error=file_recovery->file_size;
file_recovery->file_size=0;
@@ -163,7 +171,11 @@ static void file_check_ace(file_recovery_t *file_recovery)
if (le16(h.flags)&1)
{
file_recovery->file_size += le32(h.addsize);
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, file_recovery->file_size, SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle, file_recovery->file_size, SEEK_SET)<0)
+#endif
{
file_recovery->offset_error=file_recovery->file_size;
file_recovery->file_size=0;
diff --git a/src/file_axx.c b/src/file_axx.c
index 89657ea..25cf767 100644
--- a/src/file_axx.c
+++ b/src/file_axx.c
@@ -57,7 +57,11 @@ static void file_check_axx(file_recovery_t *fr)
{
struct SHeader header;
unsigned int len;
+#ifdef HAVE_FSEEKO
+ if(fseeko(fr->handle, offset, SEEK_SET) < 0)
+#else
if(fseek(fr->handle, offset, SEEK_SET) < 0)
+#endif
return ;
if (fread(&header, sizeof(header), 1, fr->handle)!=1)
return ;
diff --git a/src/file_doc.c b/src/file_doc.c
index 395b330..ad71f10 100644
--- a/src/file_doc.c
+++ b/src/file_doc.c
@@ -84,7 +84,12 @@ static void file_check_doc(file_recovery_t *file_recovery)
const uint64_t doc_file_size_org=file_recovery->file_size;
file_recovery->file_size=0;
/*reads first sector including OLE header */
- if(fseek(file_recovery->handle, 0, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, 0, SEEK_SET) < 0 ||
+#else
+ fseek(file_recovery->handle, 0, SEEK_SET) < 0 ||
+#endif
fread(&buffer_header, sizeof(buffer_header), 1, file_recovery->handle) != 1)
return ;
#ifdef DEBUG_OLE
@@ -149,7 +154,11 @@ static void file_check_doc(file_recovery_t *file_recovery)
free(fat);
return ;
}
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, (1+block)<<le16(header->uSectorShift), SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle, (1+block)<<le16(header->uSectorShift), SEEK_SET)<0)
+#endif
{
#ifdef DEBUG_OLE
log_info("fseek failed\n");
@@ -497,7 +506,11 @@ static uint32_t *OLE_load_FAT(FILE *IN, const struct OLE_HDR *header)
i<le32(header->num_extra_FAT_blocks) && block!=0xFFFFFFFF && block!=0xFFFFFFFE;
i++, block=le32(dif[109+i*(((1<<le16(header->uSectorShift))/4)-1)]))
{
+#ifdef HAVE_FSEEKO
+ if(fseeko(IN, (1+block)<<le16(header->uSectorShift), SEEK_SET) < 0)
+#else
if(fseek(IN, (1+block)<<le16(header->uSectorShift), SEEK_SET) < 0)
+#endif
{
free(dif);
return NULL;
@@ -518,7 +531,11 @@ static uint32_t *OLE_load_FAT(FILE *IN, const struct OLE_HDR *header)
j<le32(header->num_FAT_blocks);
j++, data+=(1<<le16(header->uSectorShift)))
{
+#ifdef HAVE_FSEEKO
+ if(fseeko(IN, (1+le32(dif[j]))<<le16(header->uSectorShift), SEEK_SET)<0)
+#else
if(fseek(IN, (1+le32(dif[j]))<<le16(header->uSectorShift), SEEK_SET)<0)
+#endif
{
free(dif);
free(fat);
@@ -553,7 +570,11 @@ static void *OLE_read_stream(FILE *IN,
free(dataPt);
return NULL;
}
+#ifdef HAVE_FSEEKO
+ if(fseeko(IN, (1+block)<<uSectorShift, SEEK_SET)<0)
+#else
if(fseek(IN, (1+block)<<uSectorShift, SEEK_SET)<0)
+#endif
{
free(dataPt);
return NULL;
@@ -580,7 +601,11 @@ static uint32_t *OLE_load_MiniFAT(FILE *IN, const struct OLE_HDR *header, const
block=le32(header->MiniFat_block);
for(i=0; i < le32(header->csectMiniFat) && block < fat_entries; i++)
{
+#ifdef HAVE_FSEEKO
+ if(fseeko(IN, ((uint64_t)1+block) << le16(header->uSectorShift), SEEK_SET) < 0)
+#else
if(fseek(IN, ((uint64_t)1+block) << le16(header->uSectorShift), SEEK_SET) < 0)
+#endif
{
free(minifat);
return NULL;
@@ -840,7 +865,12 @@ static void file_rename_doc(const char *old_filename)
log_info("file_rename_doc(%s)\n", old_filename);
#endif
/*reads first sector including OLE header */
- if(fseek(file, 0, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file, 0, SEEK_SET) < 0 ||
+#else
+ fseek(file, 0, SEEK_SET) < 0 ||
+#endif
fread(&buffer_header, sizeof(buffer_header), 1, file) != 1)
{
fclose(file);
@@ -877,7 +907,11 @@ static void file_rename_doc(const char *old_filename)
block=le32(fat[block]), i++)
{
struct OLE_DIR *dir_entries;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file, (1+block)<<le16(header->uSectorShift), SEEK_SET)<0)
+#else
if(fseek(file, (1+block)<<le16(header->uSectorShift), SEEK_SET)<0)
+#endif
{
free(fat);
fclose(file);
diff --git a/src/file_gif.c b/src/file_gif.c
index 68a7ce6..a4ab1d6 100644
--- a/src/file_gif.c
+++ b/src/file_gif.c
@@ -74,7 +74,12 @@ static void file_check_gif(file_recovery_t *file_recovery)
{
const unsigned char gif_footer[2]= {0x00, 0x3b};
unsigned char buffer[2];
- if(fseek(file_recovery->handle, file_recovery->calculated_file_size-2, SEEK_SET)<0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, file_recovery->calculated_file_size-2, SEEK_SET)<0 ||
+#else
+ fseek(file_recovery->handle, file_recovery->calculated_file_size-2, SEEK_SET)<0 ||
+#endif
fread(buffer, 2, 1, file_recovery->handle)!=1 ||
memcmp(buffer, gif_footer, sizeof(gif_footer))!=0)
{
diff --git a/src/file_gpg.c b/src/file_gpg.c
index ba92268..732efbc 100644
--- a/src/file_gpg.c
+++ b/src/file_gpg.c
@@ -252,7 +252,12 @@ static void file_check_gpg(file_recovery_t *file_recovery)
unsigned int length_type=0;
unsigned int length;
const int old_partial_body_length=partial_body_length;
- if(fseek(file_recovery->handle, offset, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, offset, SEEK_SET) < 0 ||
+#else
+ fseek(file_recovery->handle, offset, SEEK_SET) < 0 ||
+#endif
fread(&buffer, sizeof(buffer), 1, file_recovery->handle) != 1)
return;
@@ -313,7 +318,12 @@ static void file_check_gpg(file_recovery_t *file_recovery)
{
int len2;
unsigned char tmp[2];
- if(fseek(file_recovery->handle, offset+1+8+1+2+len, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, offset+1+8+1+2+len, SEEK_SET) < 0 ||
+#else
+ fseek(file_recovery->handle, offset+1+8+1+2+len, SEEK_SET) < 0 ||
+#endif
fread(&tmp, sizeof(tmp), 1, file_recovery->handle) != 1)
return;
mpi=(const uint16_t *)&tmp[0];
diff --git a/src/file_hdf.c b/src/file_hdf.c
index f835140..a557667 100644
--- a/src/file_hdf.c
+++ b/src/file_hdf.c
@@ -74,7 +74,12 @@ static void file_check_hdf(file_recovery_t *file_recovery)
struct ddh_struct ddh;
const struct dd_struct *p;
unsigned int i;
- if(fseek(file_recovery->handle, offset, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, offset, SEEK_SET) < 0 ||
+#else
+ fseek(file_recovery->handle, offset, SEEK_SET) < 0 ||
+#endif
fread(&ddh, sizeof(ddh), 1, file_recovery->handle) !=1 ||
be16(ddh.size)==0 ||
fread(dd, sizeof(struct dd_struct)*be16(ddh.size), 1, file_recovery->handle) !=1)
diff --git a/src/file_indd.c b/src/file_indd.c
index dbf8945..12c88c0 100644
--- a/src/file_indd.c
+++ b/src/file_indd.c
@@ -95,7 +95,11 @@ static void file_check_indd(file_recovery_t *file_recovery)
#ifdef DEBUG_INDD
log_info("file_check_indd offset=%llu (0x%llx)\n", (long long unsigned)offset, (long long unsigned)offset);
#endif
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, offset, SEEK_SET) < 0)
+#else
if(fseek(file_recovery->handle, offset, SEEK_SET) < 0)
+#endif
{
file_recovery->file_size=0;
return ;
diff --git a/src/file_jpg.c b/src/file_jpg.c
index 7251319..e74a241 100644
--- a/src/file_jpg.c
+++ b/src/file_jpg.c
@@ -286,7 +286,11 @@ static void file_check_mpo(file_recovery_t *fr)
do
{
offset+=2+size;
+#ifdef HAVE_FSEEKO
+ if(fseeko(fr->handle, offset, SEEK_SET) < 0)
+#else
if(fseek(fr->handle, offset, SEEK_SET) < 0)
+#endif
{
fr->file_size=0;
return ;
@@ -755,7 +759,11 @@ static inline int jpeg_session_resume(struct jpeg_session_struct *jpeg_session)
if(resume_memory((j_common_ptr)&jpeg_session->cinfo))
return -1;
src = (my_source_mgr *) jpeg_session->cinfo.src;
+#ifdef HAVE_FSEEKO
+ if(fseeko(jpeg_session->handle, jpeg_session->offset + src->file_size, SEEK_SET) < 0)
+#else
if(fseek(jpeg_session->handle, jpeg_session->offset + src->file_size, SEEK_SET) < 0)
+#endif
return -1;
return 0;
}
@@ -768,7 +776,11 @@ static inline void jpeg_session_suspend(struct jpeg_session_struct *jpeg_session
static void jpeg_session_start(struct jpeg_session_struct *jpeg_session)
{
+#ifdef HAVE_FSEEKO
+ if(fseeko(jpeg_session->handle, jpeg_session->offset, SEEK_SET) < 0)
+#else
if(fseek(jpeg_session->handle, jpeg_session->offset, SEEK_SET) < 0)
+#endif
{
log_critical("jpeg_session_start: fseek failed.\n");
}
@@ -1297,7 +1309,11 @@ static void jpg_search_marker(file_recovery_t *file_recovery)
return ;
offset=file_recovery->offset_error / file_recovery->blocksize * file_recovery->blocksize;
i=file_recovery->offset_error % file_recovery->blocksize;
+#ifdef HAVE_FSEEKO
+ if(fseeko(infile, offset, SEEK_SET) < 0)
+#else
if(fseek(infile, offset, SEEK_SET) < 0)
+#endif
return ;
do
{
@@ -1339,7 +1355,11 @@ static uint64_t jpg_check_structure(file_recovery_t *file_recovery, const unsign
uint64_t thumb_offset=0;
int nbytes;
file_recovery->extra=0;
+#ifdef HAVE_FSEEKO
+ if(fseeko(infile, 0, SEEK_SET) < 0)
+#else
if(fseek(infile, 0, SEEK_SET) < 0)
+#endif
return 0;
if((nbytes=fread(&buffer, 1, sizeof(buffer), infile))>0)
{
diff --git a/src/file_m2ts.c b/src/file_m2ts.c
index 07842d1..77c7358 100644
--- a/src/file_m2ts.c
+++ b/src/file_m2ts.c
@@ -79,7 +79,12 @@ static void file_rename_ts_188(const char *old_filename)
unsigned int pid;
if((file=fopen(old_filename, "rb"))==NULL)
return;
- if(fseek(file, 0, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file, 0, SEEK_SET) < 0 ||
+#else
+ fseek(file, 0, SEEK_SET) < 0 ||
+#endif
fread(&buffer, sizeof(buffer), 1, file) != 1)
{
fclose(file);
@@ -99,7 +104,12 @@ static void file_rename_ts_192(const char *old_filename)
unsigned int pid;
if((file=fopen(old_filename, "rb"))==NULL)
return;
- if(fseek(file, 0, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file, 0, SEEK_SET) < 0 ||
+#else
+ fseek(file, 0, SEEK_SET) < 0 ||
+#endif
fread(&buffer, sizeof(buffer), 1, file) != 1)
{
fclose(file);
diff --git a/src/file_mid.c b/src/file_mid.c
index 464f4b3..2c45861 100644
--- a/src/file_mid.c
+++ b/src/file_mid.c
@@ -62,7 +62,12 @@ static void file_check_midi(file_recovery_t *file_recovery)
unsigned int i;
uint64_t fs=4+4+6;
file_recovery->file_size=0;
- if(fseek(file_recovery->handle, 0, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, 0, SEEK_SET) < 0 ||
+#else
+ fseek(file_recovery->handle, 0, SEEK_SET) < 0 ||
+#endif
fread(&hdr, sizeof(hdr), 1, file_recovery->handle) != 1)
return ;
for(i=0; i<be16(hdr.tracks); i++)
@@ -71,7 +76,11 @@ static void file_check_midi(file_recovery_t *file_recovery)
#ifdef DEBUG_MIDI
log_info("file_check_midi 0x%08llx\n", (unsigned long long)fs);
#endif
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, fs, SEEK_SET) < 0 ||
+#else
if(fseek(file_recovery->handle, fs, SEEK_SET) < 0 ||
+#endif
fread(&track, 8, 1, file_recovery->handle) != 1 ||
memcmp(&track.magic[0], "MTrk", 4)!=0)
return ;
diff --git a/src/file_mig.c b/src/file_mig.c
index 01c155d..5274407 100644
--- a/src/file_mig.c
+++ b/src/file_mig.c
@@ -65,7 +65,11 @@ static void file_check_mig(file_recovery_t *file_recovery)
while(1)
{
size_t res;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, offset, SEEK_SET) < 0)
+#else
if(fseek(file_recovery->handle, offset, SEEK_SET) < 0)
+#endif
{
#ifdef DEBUG_MIG
log_info("0x%lx fseek failed\n", (long unsigned)offset);
diff --git a/src/file_mlv.c b/src/file_mlv.c
index e3bff65..add3fed 100644
--- a/src/file_mlv.c
+++ b/src/file_mlv.c
@@ -98,7 +98,12 @@ static void file_check_mlv(file_recovery_t *file_recovery)
uint64_t fs=0;
do
{
- if( fseek(file_recovery->handle, fs, SEEK_SET)<0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, fs, SEEK_SET)<0 ||
+#else
+ fseek(file_recovery->handle, fs, SEEK_SET)<0 ||
+#endif
fread(&hdr, sizeof(hdr), 1, file_recovery->handle)!=1 ||
le32(hdr.blockSize)<0x10 ||
!is_valid_type(&hdr) ||
@@ -110,7 +115,6 @@ static void file_check_mlv(file_recovery_t *file_recovery)
fs+=le32(hdr.blockSize);
} while(1);
}
-
static int header_check_mlv(const unsigned char *buffer, const unsigned int buffer_size, const unsigned int safe_header_only, const file_recovery_t *file_recovery, file_recovery_t *file_recovery_new)
{
const mlv_file_hdr_t *hdr=(const mlv_file_hdr_t *)buffer;
diff --git a/src/file_nk2.c b/src/file_nk2.c
index ee1b31b..87c40fb 100644
--- a/src/file_nk2.c
+++ b/src/file_nk2.c
@@ -112,7 +112,12 @@ static void file_check_nk2(file_recovery_t *fr)
fr->file_size = 0;
fr->offset_error=0;
fr->offset_ok=0;
- if(fseek(fr->handle, 0, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(fr->handle, 0, SEEK_SET) < 0 ||
+#else
+ fseek(fr->handle, 0, SEEK_SET) < 0 ||
+#endif
fread(&nk2h, sizeof(nk2h), 1, fr->handle)!=1)
return;
fr->file_size+=sizeof(nk2h);
@@ -187,7 +192,11 @@ static void file_check_nk2(file_recovery_t *fr)
}
#endif
fr->file_size+=sizeof(entryh);
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, fr->file_size+size, SEEK_SET) < 0)
+#else
if (fseek(fr->handle, fr->file_size+size, SEEK_SET) < 0)
+#endif
{
fr->offset_error=fr->file_size;
fr->file_size=0;
diff --git a/src/file_par2.c b/src/file_par2.c
index 20bc459..9ff7009 100644
--- a/src/file_par2.c
+++ b/src/file_par2.c
@@ -76,7 +76,11 @@ static void file_rename_par2(const char *old_filename)
int buffer_size;
unsigned char buffer[4096];
const uint64_t *lengthp=(const uint64_t *)&buffer[8];
+#ifdef HAVE_FSEEKO
+ if(fseeko(file, offset, SEEK_SET)<0)
+#else
if(fseek(file, offset, SEEK_SET)<0)
+#endif
{
fclose(file);
return;
diff --git a/src/file_pdf.c b/src/file_pdf.c
index d82a1ec..509b0a1 100644
--- a/src/file_pdf.c
+++ b/src/file_pdf.c
@@ -76,7 +76,11 @@ static void file_rename_pdf(const char *old_filename)
const unsigned char utf16[3]= { 0xfe, 0xff, 0x00};
if((handle=fopen(old_filename, "rb"))==NULL)
return;
+#ifdef HAVE_FSEEKO
+ if(fseeko(handle, 0, SEEK_END)<0)
+#else
if(fseek(handle, 0, SEEK_END)<0)
+#endif
{
fclose(handle);
return;
@@ -198,7 +202,11 @@ static void file_check_pdf_and_size(file_recovery_t *file_recovery)
int i;
int taille;
file_recovery->file_size=file_recovery->calculated_file_size;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle,file_recovery->file_size-read_size,SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle,file_recovery->file_size-read_size,SEEK_SET)<0)
+#endif
{
file_recovery->file_size=0;
return ;
@@ -230,7 +238,11 @@ static void file_date_pdf(file_recovery_t *file_recovery)
uint64_t offset=0;
unsigned int j=0;
unsigned char*buffer=(unsigned char*)MALLOC(4096);
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, 0, SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle, 0, SEEK_SET)<0)
+#endif
{
free(buffer);
return ;
@@ -252,7 +264,11 @@ static void file_date_pdf(file_recovery_t *file_recovery)
{
const unsigned char *date_asc;
struct tm tm_time;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, offset+i+1, SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle, offset+i+1, SEEK_SET)<0)
+#endif
{
free(buffer);
return ;
diff --git a/src/file_png.c b/src/file_png.c
index 6b143d3..d3e4ce7 100644
--- a/src/file_png.c
+++ b/src/file_png.c
@@ -110,7 +110,12 @@ static void file_check_png(file_recovery_t *fr)
{
char buffer[8];
const struct png_chunk *chunk=(const struct png_chunk *)&buffer;
- if(fseek(fr->handle, fr->file_size, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(fr->handle, fr->file_size, SEEK_SET) < 0 ||
+#else
+ fseek(fr->handle, fr->file_size, SEEK_SET) < 0 ||
+#endif
fread(&buffer, sizeof(buffer), 1, fr->handle) != 1)
{
fr->file_size=0;
diff --git a/src/file_riff.c b/src/file_riff.c
index 5c493ce..5c97df9 100644
--- a/src/file_riff.c
+++ b/src/file_riff.c
@@ -104,7 +104,11 @@ static void check_riff_list(file_recovery_t *fr, const unsigned int depth, const
return;
for(file_size=start; file_size < end;)
{
+#ifdef HAVE_FSEEKO
+ if(fseeko(fr->handle, file_size, SEEK_SET)<0)
+#else
if(fseek(fr->handle, file_size, SEEK_SET)<0)
+#endif
{
fr->offset_error=file_size;
return;
@@ -143,7 +147,11 @@ static void file_check_avi(file_recovery_t *fr)
{
const uint64_t file_size=fr->file_size;
riff_list_header list_header;
+#ifdef HAVE_FSEEKO
+ if(fseeko(fr->handle, fr->file_size, SEEK_SET)<0)
+#else
if(fseek(fr->handle, fr->file_size, SEEK_SET)<0)
+#endif
{
fr->file_size=0;
return ;
diff --git a/src/file_spf.c b/src/file_spf.c
index df7073a..3480df3 100644
--- a/src/file_spf.c
+++ b/src/file_spf.c
@@ -74,7 +74,11 @@ static void file_check_spf(file_recovery_t *file_recovery)
unsigned char*buffer;
buffer=(unsigned char*)MALLOC(READ_SIZE);
file_recovery->file_size=0;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, 0, SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle, 0, SEEK_SET)<0)
+#endif
{
free(buffer);
return;
diff --git a/src/file_tib.c b/src/file_tib.c
index a21f4ac..2fb9c30 100644
--- a/src/file_tib.c
+++ b/src/file_tib.c
@@ -67,7 +67,12 @@ static void file_check_tib2(file_recovery_t *file_recovery)
unsigned char*buffer=(unsigned char*)MALLOC(512);
int64_t file_size=file_recovery->calculated_file_size-512;
file_recovery->file_size = file_recovery->calculated_file_size;
- if(fseek(file_recovery->handle, file_size, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, file_size, SEEK_SET) < 0 ||
+#else
+ fseek(file_recovery->handle, file_size, SEEK_SET) < 0 ||
+#endif
fread(buffer, 1, 512, file_recovery->handle) != 512)
{
free(buffer);
@@ -83,7 +88,12 @@ static void file_check_tib2(file_recovery_t *file_recovery)
for(; file_size>0; file_size-=512)
{
unsigned int i;
- if(fseek(file_recovery->handle, file_size, SEEK_SET) < 0 ||
+ if(
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, file_size, SEEK_SET) < 0 ||
+#else
+ fseek(file_recovery->handle, file_size, SEEK_SET) < 0 ||
+#endif
fread(buffer, 1, 512, file_recovery->handle) != 512)
{
free(buffer);
diff --git a/src/file_zip.c b/src/file_zip.c
index bb542c2..68fc487 100644
--- a/src/file_zip.c
+++ b/src/file_zip.c
@@ -128,7 +128,11 @@ static int64_t file_get_pos(FILE *f, const void* needle, const unsigned int size
if (buffer[count]==*(const char *)needle && memcmp(buffer+count, needle, size)==0)
{
free(buffer);
+#ifdef HAVE_FSEEKO
+ if(fseeko(f, (long)count-read_size, SEEK_CUR)<0)
+#else
if(fseek(f, (long)count-read_size, SEEK_CUR)<0)
+#endif
return -1;
return total;
}
@@ -136,7 +140,11 @@ static int64_t file_get_pos(FILE *f, const void* needle, const unsigned int size
total++;
left--;
}
+#ifdef HAVE_FSEEKO
+ if(feof(f) || fseeko(f, (long)1-size, SEEK_CUR)<0)
+#else
if(feof(f) || fseek(f, (long)1-size, SEEK_CUR)<0)
+#endif
{
free(buffer);
return -1;
@@ -218,7 +226,11 @@ static int zip_parse_file_entry(file_recovery_t *fr, const char **ext, const uns
free(filename);
return -1;
}
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, -to_read, SEEK_CUR) < 0)
+#else
if (fseek(fr->handle, -to_read, SEEK_CUR) < 0)
+#endif
{
log_info("fseek failed\n");
free(filename);
@@ -307,8 +319,13 @@ static int zip_parse_file_entry(file_recovery_t *fr, const char **ext, const uns
log_trace("zip: Unexpected EOF in file_entry header: %lu bytes expected\n", len);
#endif
}
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, fr->file_size, SEEK_SET) == -1 ||
+ fseeko(fr->handle, len, SEEK_CUR) == -1)
+#else
if (fseek(fr->handle, fr->file_size, SEEK_SET) == -1 ||
fseek(fr->handle, len, SEEK_CUR) == -1)
+#endif
{
#ifdef DEBUG_ZIP
log_trace("zip: Unexpected EOF in file_entry header: %lu bytes expected\n", len);
@@ -326,7 +343,11 @@ static int zip_parse_file_entry(file_recovery_t *fr, const char **ext, const uns
len=krita;
if (len>0)
{
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, len, SEEK_CUR) == -1)
+#else
if (fseek(fr->handle, len, SEEK_CUR) == -1)
+#endif
{
#ifdef DEBUG_ZIP
log_trace("zip: Unexpected EOF in file_entry data: %lu bytes expected\n", len);
@@ -376,8 +397,11 @@ static int zip_parse_central_dir(file_recovery_t *fr)
uint32_t external_attr; /** External file attributes */
uint32_t offset_header; /** Relative offset of local header */
} __attribute__ ((__packed__)) dir;
-
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, 2, SEEK_CUR) == -1)
+#else
if (fseek(fr->handle, 2, SEEK_CUR) == -1)
+#endif
{
#ifdef DEBUG_ZIP
log_trace("Unexpected EOF skipping version from central_dir\n");
@@ -409,7 +433,11 @@ static int zip_parse_central_dir(file_recovery_t *fr)
/* Rest of the block - could attempt CRC check */
len = le16(file.extra_length) + le16(dir.comment_length) + le16(file.filename_length);
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, len, SEEK_CUR) == -1)
+#else
if (fseek(fr->handle, len, SEEK_CUR) == -1)
+#endif
{
#ifdef DEBUG_ZIP
log_trace("zip: Unexpected EOF in central_dir: %u bytes expected\n", len);
@@ -449,7 +477,11 @@ static int zip64_parse_end_central_dir(file_recovery_t *fr)
if (dir.end_size > 0)
{
const uint64_t len = le64(dir.end_size);
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, len, SEEK_CUR) == -1)
+#else
if (fseek(fr->handle, len, SEEK_CUR) == -1)
+#endif
{
#ifdef DEBUG_ZIP
log_trace("zip: Unexpected EOF in end_central_dir_64: expected %llu bytes\n", (long long unsigned)len);
@@ -489,7 +521,11 @@ static int zip_parse_end_central_dir(file_recovery_t *fr)
if (dir.comment_length)
{
const uint16_t len = le16(dir.comment_length);
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, len, SEEK_CUR) == -1)
+#else
if (fseek(fr->handle, len, SEEK_CUR) == -1)
+#endif
{
#ifdef DEBUG_ZIP
log_trace("zip: Unexpected EOF in end_central_dir: expected %u bytes\n", len);
@@ -547,7 +583,11 @@ static int zip_parse_signature(file_recovery_t *fr)
if (len)
{
len = le16(len);
+#ifdef HAVE_FSEEKO
+ if (fseeko(fr->handle, len, SEEK_CUR) == -1)
+#else
if (fseek(fr->handle, len, SEEK_CUR) == -1)
+#endif
{
#ifdef DEBUG_ZIP
log_trace("zip: Unexpected EOF in zip_parse_signature: expected %u bytes\n", len);
@@ -587,7 +627,11 @@ static void file_check_zip(file_recovery_t *fr)
fr->offset_error=0;
fr->offset_ok=0;
first_filename[0]='\0';
+#ifdef HAVE_FSEEKO
+ if(fseeko(fr->handle, 0, SEEK_SET) < 0)
+#else
if(fseek(fr->handle, 0, SEEK_SET) < 0)
+#endif
return ;
while (1)
{
@@ -673,7 +717,11 @@ static void file_rename_zip(const char *old_filename)
fr.file_size = 0;
fr.offset_error=0;
first_filename[0]='\0';
+#ifdef HAVE_FSEEKO
+ if(fseeko(fr.handle, 0, SEEK_SET) < 0)
+#else
if(fseek(fr.handle, 0, SEEK_SET) < 0)
+#endif
{
fclose(fr.handle);
return ;
diff --git a/src/filegen.c b/src/filegen.c
index 95fbd0f..6854363 100644
--- a/src/filegen.c
+++ b/src/filegen.c
@@ -179,7 +179,11 @@ void file_allow_nl(file_recovery_t *file_recovery, const unsigned int nl_mode)
{
unsigned char buffer[4096];
int taille;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, file_recovery->file_size,SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle, file_recovery->file_size,SEEK_SET)<0)
+#endif
return;
taille=fread(buffer,1, 4096,file_recovery->handle);
if(taille > 0 && buffer[0]=='\n' && (nl_mode&NL_BARENL)==NL_BARENL)
@@ -201,7 +205,11 @@ uint64_t file_rsearch(FILE *handle, uint64_t offset, const void*footer, const un
int taille;
const unsigned int read_size=(offset%4096!=0 ? offset%4096 : 4096);
offset-=read_size;
+#ifdef HAVE_FSEEKO
+ if(fseeko(handle,offset,SEEK_SET)<0)
+#else
if(fseek(handle,offset,SEEK_SET)<0)
+#endif
{
free(buffer);
return 0;
@@ -249,7 +257,11 @@ void file_search_lc_footer(file_recovery_t *file_recovery, const unsigned char*f
file_size=file_size-(file_size%read_size);
else
file_size-=read_size;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle,file_size,SEEK_SET)<0)
+#else
if(fseek(file_recovery->handle,file_size,SEEK_SET)<0)
+#endif
{
free(buffer);
return;
diff --git a/src/phbf.c b/src/phbf.c
index 0276353..058dc08 100644
--- a/src/phbf.c
+++ b/src/phbf.c
@@ -319,7 +319,11 @@ static bf_status_t photorec_bf_pad(struct ph_param *params, file_recovery_t *fil
uint64_t file_size_backup;
nbr=0;
offset_error_tmp=file_recovery->offset_error;
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, file_recovery->file_size, SEEK_SET) < 0)
+#else
if(fseek(file_recovery->handle, file_recovery->file_size, SEEK_SET) < 0)
+#endif
return BF_ENOENT;
#if 1
if(file_recovery->data_check!=NULL)
diff --git a/src/photorec.c b/src/photorec.c
index 9d9c2e4..170fe59 100644
--- a/src/photorec.c
+++ b/src/photorec.c
@@ -1122,7 +1122,11 @@ void file_block_truncate_and_move(file_recovery_t *file_recovery, alloc_data_t *
uint64_t i;
unsigned char *block_buffer;
block_buffer=&buffer[blocksize];
+#ifdef HAVE_FSEEKO
+ if(fseeko(file_recovery->handle, 0, SEEK_SET) < 0)
+#else
if(fseek(file_recovery->handle, 0, SEEK_SET) < 0)
+#endif
return ;
for(i=0; i< file_recovery->file_size; i+= blocksize)
{
@@ -1133,5 +1137,11 @@ void file_block_truncate_and_move(file_recovery_t *file_recovery, alloc_data_t *
}
}
else
+ {
+#ifdef HAVE_FSEEKO
+ fseeko(file_recovery->handle, file_recovery->file_size, SEEK_SET);
+#else
fseek(file_recovery->handle, file_recovery->file_size, SEEK_SET);
+#endif
+ }
}