summaryrefslogtreecommitdiffhomepage
path: root/src/core.c
diff options
context:
space:
mode:
authorRay <[email protected]>2018-10-13 15:53:02 +0200
committerGitHub <[email protected]>2018-10-13 15:53:02 +0200
commitfc4e9e7a37a0f8470c17a2b35b5611ad340a3cb2 (patch)
treeb0dbeabc15bf2ebe8da3883130996c7b3982c65a /src/core.c
parent5945805b1567c20546ae294705454733f8c071f8 (diff)
parentc2b36af60f1b2823cdeb6c8ae73a4957026d46ce (diff)
downloadraylib-fc4e9e7a37a0f8470c17a2b35b5611ad340a3cb2.tar.gz
raylib-fc4e9e7a37a0f8470c17a2b35b5611ad340a3cb2.zip
Merge pull request #661 from ChrisDill/master
Added GetLastWriteTime to allow for file reloading
Diffstat (limited to 'src/core.c')
-rw-r--r--src/core.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/core.c b/src/core.c
index e99b24b5..3b54c05c 100644
--- a/src/core.c
+++ b/src/core.c
@@ -123,6 +123,7 @@
#include <string.h> // Required for: strrchr(), strcmp()
//#include <errno.h> // Macros for reporting and retrieving error conditions through error codes
#include <ctype.h> // Required for: tolower() [Used in IsFileExtension()]
+#include <sys/stat.h> // Required for stat() [Used in GetLastWriteTime()]
#if defined(_MSC_VER)
#include "external/dirent.h" // Required for: DIR, opendir(), closedir() [Used in GetDirectoryFiles()]
@@ -1681,6 +1682,18 @@ void ClearDroppedFiles(void)
#endif
}
+// Get the last write time of a file
+long GetLastWriteTime(const char *fileName)
+{
+ struct stat result = {0};
+ if (stat(fileName, &result) == 0)
+ {
+ time_t mod = result.st_mtime;
+ return mod;
+ }
+ return 0;
+}
+
// Save integer value to storage file (to defined position)
// NOTE: Storage positions is directly related to file memory layout (4 bytes each integer)
void StorageSaveValue(int position, int value)