summaryrefslogtreecommitdiff
path: root/firmware/target
diff options
context:
space:
mode:
authorJames Buren <braewoods+rb@braewoods.net>2021-07-11 12:40:08 +0000
committerJames Buren <braewoods+rb@braewoods.net>2021-07-11 12:40:08 +0000
commitfa743258ea963b9b924204f0d80e077056cf9a6e (patch)
tree603c11a1d0e6013752e78539df43c062c58676e5 /firmware/target
parent8846e087c09c28a2dfb731d7c873f113bc899940 (diff)
filesystem: implement os_modtime for unix
Change-Id: If030d526f29aa786b5a37402413d804752286cf5
Diffstat (limited to 'firmware/target')
-rw-r--r--firmware/target/hosted/filesystem-app.h1
-rw-r--r--firmware/target/hosted/filesystem-hosted.h1
-rw-r--r--firmware/target/hosted/filesystem-unix.c12
3 files changed, 14 insertions, 0 deletions
diff --git a/firmware/target/hosted/filesystem-app.h b/firmware/target/hosted/filesystem-app.h
index 68b3f13b6e..b35b63e95f 100644
--- a/firmware/target/hosted/filesystem-app.h
+++ b/firmware/target/hosted/filesystem-app.h
@@ -82,6 +82,7 @@ ssize_t app_write(int fildes, const void *buf, size_t nbyte);
#endif /* HAVE_SDL_THREADS */
int app_remove(const char *path);
int app_rename(const char *old, const char *new);
+#define app_modtime os_modtime
#define app_filesize os_filesize
#define app_fsamefile os_fsamefile
int app_relate(const char *path1, const char *path2);
diff --git a/firmware/target/hosted/filesystem-hosted.h b/firmware/target/hosted/filesystem-hosted.h
index 5147ef6db6..b9c7ce648a 100644
--- a/firmware/target/hosted/filesystem-hosted.h
+++ b/firmware/target/hosted/filesystem-hosted.h
@@ -33,6 +33,7 @@ void * os_lc_open(const char *ospath);
#define _FILESYSTEM_HOSTED__FILE_H_
#ifndef OSFUNCTIONS_DECLARED
+int os_modtime(const char *path, time_t modtime);
off_t os_filesize(int osfd);
int os_fsamefile(int osfd1, int osfd2);
int os_relate(const char *path1, const char *path2);
diff --git a/firmware/target/hosted/filesystem-unix.c b/firmware/target/hosted/filesystem-unix.c
index 177cb574e0..f0d7de640d 100644
--- a/firmware/target/hosted/filesystem-unix.c
+++ b/firmware/target/hosted/filesystem-unix.c
@@ -23,6 +23,7 @@
#include <sys/stat.h>
#include <string.h>
#include <errno.h>
+#include <utime.h>
#include "config.h"
#include "system.h"
#include "file.h"
@@ -35,6 +36,17 @@
#define SAME_FILE_INFO(sb1p, sb2p) \
((sb1p)->st_dev == (sb2p)->st_dev && (sb1p)->st_ino == (sb2p)->st_ino)
+int os_modtime(const char *path, time_t modtime)
+{
+ struct utimbuf times =
+ {
+ .actime = modtime,
+ .modtime = modtime,
+ };
+
+ return utime(path, &times);
+}
+
off_t os_filesize(int osfd)
{
struct stat sb;