summaryrefslogtreecommitdiff
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
parent8846e087c09c28a2dfb731d7c873f113bc899940 (diff)
downloadrockbox-fa743258ea963b9b924204f0d80e077056cf9a6e.tar.gz
rockbox-fa743258ea963b9b924204f0d80e077056cf9a6e.zip
filesystem: implement os_modtime for unix
Change-Id: If030d526f29aa786b5a37402413d804752286cf5
-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);
82#endif /* HAVE_SDL_THREADS */ 82#endif /* HAVE_SDL_THREADS */
83int app_remove(const char *path); 83int app_remove(const char *path);
84int app_rename(const char *old, const char *new); 84int app_rename(const char *old, const char *new);
85#define app_modtime os_modtime
85#define app_filesize os_filesize 86#define app_filesize os_filesize
86#define app_fsamefile os_fsamefile 87#define app_fsamefile os_fsamefile
87int app_relate(const char *path1, const char *path2); 88int 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);
33#define _FILESYSTEM_HOSTED__FILE_H_ 33#define _FILESYSTEM_HOSTED__FILE_H_
34 34
35#ifndef OSFUNCTIONS_DECLARED 35#ifndef OSFUNCTIONS_DECLARED
36int os_modtime(const char *path, time_t modtime);
36off_t os_filesize(int osfd); 37off_t os_filesize(int osfd);
37int os_fsamefile(int osfd1, int osfd2); 38int os_fsamefile(int osfd1, int osfd2);
38int os_relate(const char *path1, const char *path2); 39int 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 @@
23#include <sys/stat.h> 23#include <sys/stat.h>
24#include <string.h> 24#include <string.h>
25#include <errno.h> 25#include <errno.h>
26#include <utime.h>
26#include "config.h" 27#include "config.h"
27#include "system.h" 28#include "system.h"
28#include "file.h" 29#include "file.h"
@@ -35,6 +36,17 @@
35#define SAME_FILE_INFO(sb1p, sb2p) \ 36#define SAME_FILE_INFO(sb1p, sb2p) \
36 ((sb1p)->st_dev == (sb2p)->st_dev && (sb1p)->st_ino == (sb2p)->st_ino) 37 ((sb1p)->st_dev == (sb2p)->st_dev && (sb1p)->st_ino == (sb2p)->st_ino)
37 38
39int os_modtime(const char *path, time_t modtime)
40{
41 struct utimbuf times =
42 {
43 .actime = modtime,
44 .modtime = modtime,
45 };
46
47 return utime(path, &times);
48}
49
38off_t os_filesize(int osfd) 50off_t os_filesize(int osfd)
39{ 51{
40 struct stat sb; 52 struct stat sb;