mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-04 18:42:15 +02:00
Merge commit '66a4db694b53a762c24cb381a3ec458b525e43c9' into ncm-new-ipc
This commit is contained in:
commit
bac93d9b41
@ -168,14 +168,14 @@ typedef enum
|
|||||||
FsWriteOption_Flush = BIT(0), ///< Forces a flush after write.
|
FsWriteOption_Flush = BIT(0), ///< Forces a flush after write.
|
||||||
} FsWriteOption;
|
} FsWriteOption;
|
||||||
|
|
||||||
typedef enum
|
/// StorageId
|
||||||
{
|
typedef enum {
|
||||||
FsStorageId_None = 0,
|
FsStorageId_None = 0, ///< None
|
||||||
FsStorageId_Host = 1,
|
FsStorageId_Host = 1, ///< Host
|
||||||
FsStorageId_GameCard = 2,
|
FsStorageId_GameCard = 2, ///< GameCard
|
||||||
FsStorageId_NandSystem = 3,
|
FsStorageId_NandSystem = 3, ///< NandSystem
|
||||||
FsStorageId_NandUser = 4,
|
FsStorageId_NandUser = 4, ///< NandUser
|
||||||
FsStorageId_SdCard = 5,
|
FsStorageId_SdCard = 5, ///< SdCard
|
||||||
} FsStorageId;
|
} FsStorageId;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
@ -65,8 +65,8 @@ Result timeLoadLocationNameList(u32 index, TimeLocationName *location_name_array
|
|||||||
|
|
||||||
Result timeLoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule);
|
Result timeLoadTimeZoneRule(const TimeLocationName *name, TimeZoneRule *rule);
|
||||||
|
|
||||||
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_size, u32 *timestamp_count);
|
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count);
|
||||||
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_size, u32 *timestamp_count);
|
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count);
|
||||||
Result timeToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
|
Result timeToCalendarTime(const TimeZoneRule *rule, u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
|
||||||
Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
|
Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, TimeCalendarAdditionalInfo *info);
|
||||||
|
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
#include <sys/iosupport.h>
|
#include <sys/iosupport.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
#include "runtime/devices/fs_dev.h"
|
#include "runtime/devices/fs_dev.h"
|
||||||
#include "runtime/util/utf.h"
|
#include "runtime/util/utf.h"
|
||||||
#include "services/fs.h"
|
#include "services/fs.h"
|
||||||
|
#include "services/time.h"
|
||||||
|
|
||||||
|
|
||||||
/*! @internal
|
/*! @internal
|
||||||
@ -256,6 +258,28 @@ static ssize_t fsdev_convertfromfspath(uint8_t *out, uint8_t *in, size_t len)
|
|||||||
return strnlen((char*)out, len);
|
return strnlen((char*)out, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static time_t fsdev_converttimetoutc(u64 timestamp)
|
||||||
|
{
|
||||||
|
// Parse timestamp into y/m/d h:m:s
|
||||||
|
time_t posixtime = (time_t)timestamp;
|
||||||
|
struct tm *t = gmtime(&posixtime);
|
||||||
|
|
||||||
|
// Convert time/date into an actual UTC POSIX timestamp using the system's timezone rules
|
||||||
|
TimeCalendarTime caltime;
|
||||||
|
caltime.year = 1900 + t->tm_year;
|
||||||
|
caltime.month = 1 + t->tm_mon;
|
||||||
|
caltime.day = t->tm_mday;
|
||||||
|
caltime.hour = t->tm_hour;
|
||||||
|
caltime.minute = t->tm_min;
|
||||||
|
caltime.second = t->tm_sec;
|
||||||
|
u64 new_timestamp;
|
||||||
|
Result rc = timeToPosixTimeWithMyRule(&caltime, &new_timestamp, 1, NULL);
|
||||||
|
if (R_SUCCEEDED(rc))
|
||||||
|
posixtime = (time_t)new_timestamp;
|
||||||
|
|
||||||
|
return posixtime;
|
||||||
|
}
|
||||||
|
|
||||||
extern int __system_argc;
|
extern int __system_argc;
|
||||||
extern char** __system_argv;
|
extern char** __system_argv;
|
||||||
|
|
||||||
@ -965,9 +989,9 @@ fsdev_fstat(struct _reent *r,
|
|||||||
|
|
||||||
if(file->timestamps.is_valid)
|
if(file->timestamps.is_valid)
|
||||||
{
|
{
|
||||||
st->st_ctime = file->timestamps.created;
|
st->st_ctime = fsdev_converttimetoutc(file->timestamps.created);
|
||||||
st->st_mtime = file->timestamps.modified;
|
st->st_mtime = fsdev_converttimetoutc(file->timestamps.modified);
|
||||||
st->st_atime = file->timestamps.accessed;
|
st->st_atime = fsdev_converttimetoutc(file->timestamps.accessed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1030,9 +1054,9 @@ fsdev_stat(struct _reent *r,
|
|||||||
rc = fsFsGetFileTimeStampRaw(&device->fs, fs_path, ×tamps);
|
rc = fsFsGetFileTimeStampRaw(&device->fs, fs_path, ×tamps);
|
||||||
if(R_SUCCEEDED(rc) && timestamps.is_valid)
|
if(R_SUCCEEDED(rc) && timestamps.is_valid)
|
||||||
{
|
{
|
||||||
st->st_ctime = timestamps.created;
|
st->st_ctime = fsdev_converttimetoutc(timestamps.created);
|
||||||
st->st_mtime = timestamps.modified;
|
st->st_mtime = fsdev_converttimetoutc(timestamps.modified);
|
||||||
st->st_atime = timestamps.accessed;
|
st->st_atime = fsdev_converttimetoutc(timestamps.accessed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,11 +440,14 @@ Result timeToCalendarTimeWithMyRule(u64 timestamp, TimeCalendarTime *caltime, Ti
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_size, u32 *timestamp_count) {
|
Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count) {
|
||||||
|
if (!serviceIsActive(&g_timeTimeZoneService))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
|
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
ipcAddSendBuffer(&c, rule, sizeof(TimeZoneRule), BufferType_Normal);
|
ipcAddSendBuffer(&c, rule, sizeof(TimeZoneRule), BufferType_Normal);
|
||||||
ipcAddRecvStatic(&c, timestamp_list, timestamp_list_size, 0);
|
ipcAddRecvStatic(&c, timestamp_list, sizeof(u64)*timestamp_list_count, 0);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u64 magic;
|
u64 magic;
|
||||||
@ -478,10 +481,13 @@ Result timeToPosixTime(const TimeZoneRule *rule, const TimeCalendarTime *caltime
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_size, u32 *timestamp_count) {
|
Result timeToPosixTimeWithMyRule(const TimeCalendarTime *caltime, u64 *timestamp_list, size_t timestamp_list_count, u32 *timestamp_count) {
|
||||||
|
if (!serviceIsActive(&g_timeTimeZoneService))
|
||||||
|
return MAKERESULT(Module_Libnx, LibnxError_NotInitialized);
|
||||||
|
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
ipcAddRecvStatic(&c, timestamp_list, timestamp_list_size, 0);
|
ipcAddRecvStatic(&c, timestamp_list, sizeof(u64)*timestamp_list_count, 0);
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
u64 magic;
|
u64 magic;
|
||||||
|
Loading…
Reference in New Issue
Block a user