| iMatix home page | << | < | > | >> |
SFL Version 2.11 |
#include "sflfile.h" time_t get_file_time ( const char *filename)
Returns the modification time of the specified file or directory. The returned time is suitable for feeding to localtime().
{ #if (defined (WIN32_NOT_IMPLEMENTED)) /* This code has been disactivated because it returns incorrect values depending on the seasonal clock change. */ unsigned long thi,tlo; double dthi,dtlo; double secs_since_1601, secs_time_t; double delta = 11644473600.; double two_to_32 = 4294967296.; HANDLE handle; FILETIME creation, last_access, last_write; handle = CreateFile (filename, GENERIC_READ, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0); if (handle == INVALID_HANDLE_VALUE) return (0); GetFileTime (handle, &creation, &last_access, &last_write); CloseHandle (handle); thi = last_write.dwHighDateTime; tlo = last_write.dwLowDateTime; dthi = (double) thi; dtlo = (double) tlo; secs_since_1601 = (dthi * two_to_32 + dtlo) / 1.0e7; secs_time_t = secs_since_1601 - delta; return ((time_t) secs_time_t); #else struct stat stat_buf; ASSERT (filename); # if (defined (MSDOS_FILESYSTEM)) if (system_devicename (filename)) return (0); /* Not allowed on device names */ # endif if (stat ((char *) filename, &stat_buf) == 0) return (stat_buf.st_mtime > 0? stat_buf.st_mtime: 0); else return (0); #endif }
| << | < | > | >> | Copyright © 1996-2000 iMatix Corporation |