summaryrefslogtreecommitdiffstats
path: root/src/file_pdf.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/file_pdf.c')
-rw-r--r--src/file_pdf.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/src/file_pdf.c b/src/file_pdf.c
index 9be41c3..c62b9bf 100644
--- a/src/file_pdf.c
+++ b/src/file_pdf.c
@@ -245,38 +245,18 @@ static void file_date_pdf(file_recovery_t *file_recovery)
{
if(++j==sizeof(pattern))
{
- const unsigned char *date_asc;
- struct tm tm_time;
- if(my_fseek(file_recovery->handle, offset+i+1, SEEK_SET)<0)
+ if(my_fseek(file_recovery->handle, offset+i+1, SEEK_SET)>=0 &&
+ fread(buffer, 1, 22, file_recovery->handle) == 22)
{
- free(buffer);
- return ;
+ if(buffer[0]=='=' && (buffer[1]=='\'' || buffer[1]=='"'))
+ {
+ file_recovery->time=get_time_from_YYYY_MM_DD_HH_MM_SS((const char *)&buffer[2]);
+ }
+ else if(buffer[0]=='>')
+ {
+ file_recovery->time=get_time_from_YYYY_MM_DD_HH_MM_SS((const char *)&buffer[1]);
+ }
}
- if(fread(buffer, 1, 22, file_recovery->handle) < 22)
- {
- free(buffer);
- return ;
- }
- if(buffer[0]=='=' && (buffer[1]=='\'' || buffer[1]=='"'))
- date_asc=&buffer[2];
- else if(buffer[i]=='>')
- date_asc=&buffer[1];
- else
- {
- free(buffer);
- return ;
- }
- /* */
- memset(&tm_time, 0, sizeof(tm_time));
- tm_time.tm_sec=(date_asc[17]-'0')*10+(date_asc[18]-'0'); /* seconds 0-59 */
- tm_time.tm_min=(date_asc[14]-'0')*10+(date_asc[15]-'0'); /* minutes 0-59 */
- tm_time.tm_hour=(date_asc[11]-'0')*10+(date_asc[12]-'0'); /* hours 0-23*/
- tm_time.tm_mday=(date_asc[8]-'0')*10+(date_asc[9]-'0'); /* day of the month 1-31 */
- tm_time.tm_mon=(date_asc[5]-'0')*10+(date_asc[6]-'0')-1; /* month 0-11 */
- tm_time.tm_year=(date_asc[0]-'0')*1000+(date_asc[1]-'0')*100+
- (date_asc[2]-'0')*10+(date_asc[3]-'0')-1900; /* year */
- tm_time.tm_isdst = -1; /* unknown daylight saving time */
- file_recovery->time=mktime(&tm_time);
free(buffer);
return ;
}