From f09b6915ae0816c6becdb2b279b55d01fa2c7da9 Mon Sep 17 00:00:00 2001 From: rswindell <> Date: Thu, 16 Nov 2017 07:16:28 +0000 Subject: [PATCH] Created fcdate() to return file creation (rather than mod) time_t. --- src/xpdev/dirwrap.c | 19 +++++++++++++++++-- src/xpdev/dirwrap.h | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/xpdev/dirwrap.c b/src/xpdev/dirwrap.c index 5bfbaa2ede..160de88e4c 100644 --- a/src/xpdev/dirwrap.c +++ b/src/xpdev/dirwrap.c @@ -1,6 +1,5 @@ -/* dirwrap.c */ - /* Directory-related system-call wrappers */ +// vi: tabstop=4 /* $Id$ */ @@ -389,6 +388,22 @@ void DLLCALL rewinddir(DIR* dir) } #endif /* defined(_MSC_VER) */ +/****************************************************************************/ +/* Returns the creation time of the file 'filename' in time_t format */ +/****************************************************************************/ +time_t DLLCALL fcdate(const char* filename) +{ + struct stat st; + + if(access(filename, 0) < 0) + return -1; + + if(stat(filename, &st) != 0) + return -1; + + return st.st_ctime; +} + /****************************************************************************/ /* Returns the time/date of the file in 'filename' in time_t (unix) format */ /****************************************************************************/ diff --git a/src/xpdev/dirwrap.h b/src/xpdev/dirwrap.h index dd3de391ee..1087bb227f 100644 --- a/src/xpdev/dirwrap.h +++ b/src/xpdev/dirwrap.h @@ -1,6 +1,5 @@ -/* dirwrap.h */ - /* Directory system-call wrappers */ +// vi: tabstop=4 /* $Id$ */ @@ -220,6 +219,7 @@ DLLEXPORT BOOL DLLCALL fexist(const char *filespec); DLLEXPORT BOOL DLLCALL fexistcase(char *filespec); /* fixes upr/lwr case fname */ DLLEXPORT off_t DLLCALL flength(const char *filename); DLLEXPORT time_t DLLCALL fdate(const char *filename); +DLLEXPORT time_t DLLCALL fcdate(const char* filename); DLLEXPORT int DLLCALL setfdate(const char* filename, time_t t); DLLEXPORT BOOL DLLCALL isdir(const char *filename); DLLEXPORT BOOL DLLCALL isabspath(const char *filename); -- GitLab