blob: 4bf2adfaa4619b4958593e0f3824c0b999f5cd80 [file] [log] [blame]
Guido van Rossumbe0e9421993-12-24 10:32:00 +00001/***********************************************************
Guido van Rossum6d023c91995-01-04 19:12:13 +00002Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam,
3The Netherlands.
Guido van Rossumbe0e9421993-12-24 10:32:00 +00004
5 All Rights Reserved
6
Guido van Rossumd266eb41996-10-25 14:44:06 +00007Permission to use, copy, modify, and distribute this software and its
8documentation for any purpose and without fee is hereby granted,
Guido van Rossumbe0e9421993-12-24 10:32:00 +00009provided that the above copyright notice appear in all copies and that
Guido van Rossumd266eb41996-10-25 14:44:06 +000010both that copyright notice and this permission notice appear in
Guido van Rossumbe0e9421993-12-24 10:32:00 +000011supporting documentation, and that the names of Stichting Mathematisch
Guido van Rossumd266eb41996-10-25 14:44:06 +000012Centrum or CWI or Corporation for National Research Initiatives or
13CNRI not be used in advertising or publicity pertaining to
14distribution of the software without specific, written prior
15permission.
Guido van Rossumbe0e9421993-12-24 10:32:00 +000016
Guido van Rossumd266eb41996-10-25 14:44:06 +000017While CWI is the initial source for this software, a modified version
18is made available by the Corporation for National Research Initiatives
19(CNRI) at the Internet address ftp://ftp.python.org.
20
21STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
23MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH
24CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
25DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
26PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
27TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
28PERFORMANCE OF THIS SOFTWARE.
Guido van Rossumbe0e9421993-12-24 10:32:00 +000029
30******************************************************************/
31
32/* Subroutine to get the last modification time of a file */
33
34/* (A separate file because this may be OS dependent) */
35
Guido van Rossumb6775db1994-08-01 11:34:53 +000036#include "config.h"
Guido van Rossumb6775db1994-08-01 11:34:53 +000037
Guido van Rossumaee0bad1997-09-05 07:33:22 +000038#include <stdio.h>
Guido van Rossumbe0e9421993-12-24 10:32:00 +000039#include <sys/types.h>
40#include <sys/stat.h>
Guido van Rossumbe0e9421993-12-24 10:32:00 +000041
42long
Guido van Rossumaee0bad1997-09-05 07:33:22 +000043PyOS_GetLastModificationTime(path, fp)
Guido van Rossumbe0e9421993-12-24 10:32:00 +000044 char *path;
Guido van Rossumaee0bad1997-09-05 07:33:22 +000045 FILE *fp;
Guido van Rossumbe0e9421993-12-24 10:32:00 +000046{
47 struct stat st;
Guido van Rossumaee0bad1997-09-05 07:33:22 +000048 if (fstat(fileno(fp), &st) != 0)
Guido van Rossumbe0e9421993-12-24 10:32:00 +000049 return -1;
50 else
51 return st.st_mtime;
52}