(#885) Introduce system/file module

master
rexim 2019-06-16 01:00:59 +07:00
parent 9d9a8f5891
commit 608f4b1c81
3 changed files with 30 additions and 0 deletions

View File

@ -154,6 +154,8 @@ add_executable(nothing
src/game/level/level_editor/layer.c
src/game/level/level_editor/label_layer.c
src/game/level/level_editor/label_layer.h
src/system/file.h
src/system/file.c
)
target_link_libraries(nothing ${SDL2_LIBRARIES} system ebisp)

20
src/system/file.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef __linux__
#include <sys/stat.h>
#include <sys/types.h>
#endif // __linux__
#include "system/stacktrace.h"
#include "file.h"
time_t last_modified(const char *filepath)
{
trace_assert(filepath);
#ifdef __linux__
struct stat attr;
stat(filepath, &attr);
return attr.st_mtime;
#endif // __linux__
}

8
src/system/file.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef FILE_H_
#define FILE_H_
#include <time.h>
time_t last_modified(const char *filepath);
#endif // FILE_H_