use int64 fr file_time
This commit is contained in:
parent
fef0538157
commit
c60e1046a7
78
os/pl-files.c
Normal file → Executable file
78
os/pl-files.c
Normal file → Executable file
@ -105,12 +105,13 @@ LastModifiedFile(const char *name, double *tp)
|
|||||||
if ( rc )
|
if ( rc )
|
||||||
{ double t;
|
{ double t;
|
||||||
|
|
||||||
|
fprintf(stderr, "wt.dwHighDateTime=%ld wt.dwLowDateTime=%ld\n",wt.dwHighDateTime, wt.dwLowDateTime);
|
||||||
t = (double)wt.dwHighDateTime * (4294967296.0 * ntick nano);
|
t = (double)wt.dwHighDateTime * (4294967296.0 * ntick nano);
|
||||||
t += (double)wt.dwLowDateTime * (ntick nano);
|
t += (double)wt.dwLowDateTime * (ntick nano);
|
||||||
t -= SEC_TO_UNIX_EPOCH;
|
t -= SEC_TO_UNIX_EPOCH;
|
||||||
|
|
||||||
*tp = t;
|
*tp = t;
|
||||||
|
fprintf(stderr, " t=%f\n", t);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,6 +131,63 @@ LastModifiedFile(const char *name, double *tp)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
LastModifiedFile64(const char *name, int64_t *tp)
|
||||||
|
{
|
||||||
|
#ifdef __WINDOWS__
|
||||||
|
HANDLE hFile;
|
||||||
|
wchar_t wfile[MAXPATHLEN];
|
||||||
|
|
||||||
|
#define nano * 0.000000001
|
||||||
|
#define ntick 100.0
|
||||||
|
#define SEC_TO_UNIX_EPOCH 11644473600.0
|
||||||
|
|
||||||
|
if ( !_xos_os_filenameW(name, wfile, MAXPATHLEN) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if ( (hFile=CreateFileW(wfile,
|
||||||
|
0,
|
||||||
|
FILE_SHARE_DELETE|FILE_SHARE_READ|FILE_SHARE_WRITE,
|
||||||
|
NULL,
|
||||||
|
OPEN_EXISTING,
|
||||||
|
FILE_FLAG_BACKUP_SEMANTICS,
|
||||||
|
NULL)) != INVALID_HANDLE_VALUE )
|
||||||
|
{ FILETIME wt;
|
||||||
|
int rc;
|
||||||
|
|
||||||
|
rc = GetFileTime(hFile, NULL, NULL, (FILETIME *)&wt);
|
||||||
|
CloseHandle(hFile);
|
||||||
|
|
||||||
|
if ( rc )
|
||||||
|
{
|
||||||
|
LARGE_INTEGER date, adjust;
|
||||||
|
date.HighPart = wt.dwHighDateTime;
|
||||||
|
date.LowPart = wt.dwLowDateTime;
|
||||||
|
|
||||||
|
adjust.QuadPart = 11644473600000 * 10000;
|
||||||
|
date.QuadPart -= adjust.QuadPart;
|
||||||
|
date.QuadPart /= 10000000;
|
||||||
|
|
||||||
|
*tp = date.QuadPart;
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
set_posix_error(GetLastError());
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
#else
|
||||||
|
char tmp[MAXPATHLEN];
|
||||||
|
statstruct buf;
|
||||||
|
|
||||||
|
if ( statfunc(OsPath(name, tmp), &buf) < 0 )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
*tp = (int64_t)buf.st_mtime;
|
||||||
|
return TRUE;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/** static int64_t SizeFile(const char *path)
|
/** static int64_t SizeFile(const char *path)
|
||||||
|
|
||||||
@ -602,6 +660,23 @@ PRED_IMPL("time_file", 2, time_file, 0)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static
|
||||||
|
PRED_IMPL("time_file64", 2, time_file64, 0)
|
||||||
|
{ char *fn;
|
||||||
|
|
||||||
|
if ( PL_get_file_name(A1, &fn, 0) )
|
||||||
|
{ int64_t time;
|
||||||
|
|
||||||
|
if ( LastModifiedFile64(fn, &time) )
|
||||||
|
return PL_unify_int64(A2, time);
|
||||||
|
|
||||||
|
return PL_error(NULL, 0, NULL, ERR_FILE_OPERATION,
|
||||||
|
ATOM_time, ATOM_file, A1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static
|
static
|
||||||
PRED_IMPL("size_file", 2, size_file, 0)
|
PRED_IMPL("size_file", 2, size_file, 0)
|
||||||
@ -1119,6 +1194,7 @@ BeginPredDefs(files)
|
|||||||
PRED_DEF("working_directory", 2, working_directory, 0)
|
PRED_DEF("working_directory", 2, working_directory, 0)
|
||||||
PRED_DEF("access_file", 2, access_file, 0)
|
PRED_DEF("access_file", 2, access_file, 0)
|
||||||
PRED_DEF("time_file", 2, time_file, 0)
|
PRED_DEF("time_file", 2, time_file, 0)
|
||||||
|
PRED_DEF("time_file64", 2, time_file64, 0)
|
||||||
PRED_DEF("size_file", 2, size_file, 0)
|
PRED_DEF("size_file", 2, size_file, 0)
|
||||||
PRED_DEF("read_link", 3, read_link, 0)
|
PRED_DEF("read_link", 3, read_link, 0)
|
||||||
PRED_DEF("exists_file", 1, exists_file, 0)
|
PRED_DEF("exists_file", 1, exists_file, 0)
|
||||||
|
6
pl/consult.yap
Normal file → Executable file
6
pl/consult.yap
Normal file → Executable file
@ -561,8 +561,8 @@ prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :-
|
|||||||
'$file_is_unchanged'(F, R, Age).
|
'$file_is_unchanged'(F, R, Age).
|
||||||
|
|
||||||
'$file_is_unchanged'(F, R, Age) :-
|
'$file_is_unchanged'(F, R, Age) :-
|
||||||
time_file(F,CurrentAge),
|
time_file64(F,CurrentAge),
|
||||||
((CurrentAge = Age ; Age = -1) -> true; erase(R), fail).
|
( (Age == CurrentAge ; Age = -1) -> true; erase(R), fail).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -645,7 +645,7 @@ remove_from_path(New) :- '$check_path'(New,Path),
|
|||||||
Stream \= user_input,
|
Stream \= user_input,
|
||||||
'$file_name'(Stream,F),
|
'$file_name'(Stream,F),
|
||||||
( recorded('$lf_loaded','$lf_loaded'(F,M,_,_),R), erase(R), fail ; true ),
|
( recorded('$lf_loaded','$lf_loaded'(F,M,_,_),R), erase(R), fail ; true ),
|
||||||
time_file(F,Age),
|
time_file64(F,Age),
|
||||||
recorda('$lf_loaded','$lf_loaded'(F,M,Age,Reconsult),_),
|
recorda('$lf_loaded','$lf_loaded'(F,M,Age,Reconsult),_),
|
||||||
fail.
|
fail.
|
||||||
'$record_loaded'(_, _, _).
|
'$record_loaded'(_, _, _).
|
||||||
|
Reference in New Issue
Block a user