blob: 54edb531df9f07b20583f323f1894881f20ba73c [file] [log] [blame]
Guido van Rossumbe0e9421993-12-24 10:32:00 +00001
2/* Subroutine to get the last modification time of a file */
3
4/* (A separate file because this may be OS dependent) */
5
Fred Drake4c82b232000-06-30 16:18:57 +00006#include "Python.h"
Martin v. Löwis4f1cd8b2001-07-26 13:41:06 +00007#include "pyconfig.h"
Guido van Rossumb6775db1994-08-01 11:34:53 +00008
Anthony Baxterac6bd462006-04-13 02:06:09 +00009#ifdef __cplusplus
10extern "C" {
11#endif
12
Fred Drake4c82b232000-06-30 16:18:57 +000013time_t
Thomas Woutersf70ef4f2000-07-22 18:47:25 +000014PyOS_GetLastModificationTime(char *path, FILE *fp)
Guido van Rossumbe0e9421993-12-24 10:32:00 +000015{
16 struct stat st;
Guido van Rossumaee0bad1997-09-05 07:33:22 +000017 if (fstat(fileno(fp), &st) != 0)
Guido van Rossumbe0e9421993-12-24 10:32:00 +000018 return -1;
19 else
20 return st.st_mtime;
21}
Anthony Baxterac6bd462006-04-13 02:06:09 +000022
23#ifdef __cplusplus
24}
25#endif
26