mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
LibC: Implement utimes function
This commit is contained in:
parent
eab151c994
commit
3c390d65e4
Notes:
sideshowbarker
2024-07-18 20:58:10 +09:00
Author: https://github.com/gmta Commit: https://github.com/SerenityOS/serenity/commit/3c390d65e4f Pull-request: https://github.com/SerenityOS/serenity/pull/6002
2 changed files with 12 additions and 0 deletions
|
@ -45,6 +45,7 @@ struct timezone {
|
|||
int adjtime(const struct timeval* delta, struct timeval* old_delta);
|
||||
int gettimeofday(struct timeval* __restrict__, void* __restrict__) __attribute__((nonnull(1)));
|
||||
int settimeofday(struct timeval* __restrict__, void* __restrict__) __attribute__((nonnull(1)));
|
||||
int utimes(const char* pathname, const struct timeval[2]);
|
||||
|
||||
static inline void timeradd(const struct timeval* a, const struct timeval* b, struct timeval* out)
|
||||
{
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include <sys/times.h>
|
||||
#include <syscall.h>
|
||||
#include <time.h>
|
||||
#include <utime.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
|
@ -68,6 +69,16 @@ int settimeofday(struct timeval* __restrict__ tv, void* __restrict__)
|
|||
return clock_settime(CLOCK_REALTIME, &ts);
|
||||
}
|
||||
|
||||
int utimes(const char* pathname, const struct timeval times[2])
|
||||
{
|
||||
if (!times) {
|
||||
return utime(pathname, nullptr);
|
||||
}
|
||||
// FIXME: implement support for tv_usec in the utime (or a new) syscall
|
||||
utimbuf buf = { times[0].tv_sec, times[1].tv_sec };
|
||||
return utime(pathname, &buf);
|
||||
}
|
||||
|
||||
char* ctime(const time_t* t)
|
||||
{
|
||||
return asctime(localtime(t));
|
||||
|
|
Loading…
Add table
Reference in a new issue