mirror of
https://github.com/SysRay/psOff_public.git
synced 2024-11-23 06:19:41 +00:00
+ libsceRtc
This commit is contained in:
parent
e905c10b73
commit
08ed73f47c
18
modules/libSceRtc/CMakeLists.txt
Normal file
18
modules/libSceRtc/CMakeLists.txt
Normal file
@ -0,0 +1,18 @@
|
||||
cmake_minimum_required(VERSION 3.24)
|
||||
include(../setupModule.cmake)
|
||||
|
||||
set(libName libSceRtc)
|
||||
project(${libName})
|
||||
|
||||
add_library(${libName} SHARED entry.cpp)
|
||||
|
||||
add_dependencies(${libName} third_party)
|
||||
target_link_libraries(${libName} PRIVATE
|
||||
libboost_chrono
|
||||
)
|
||||
|
||||
target_compile_definitions(${libName} PRIVATE
|
||||
BOOST_ALL_NO_LIB
|
||||
)
|
||||
|
||||
setupModule(${libName})
|
19
modules/libSceRtc/codes.h
Normal file
19
modules/libSceRtc/codes.h
Normal file
@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Err {
|
||||
constexpr int32_t SCE_RTC_ERROR_NOT_INITIALIZED = -2135621631;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_POINTER = -2135621630;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_VALUE = -2135621629;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_ARG = -2135621628;
|
||||
constexpr int32_t SCE_RTC_ERROR_NOT_SUPPORTED = -2135621627;
|
||||
constexpr int32_t SCE_RTC_ERROR_NO_CLOCK = -2135621626;
|
||||
constexpr int32_t SCE_RTC_ERROR_BAD_PARSE = -2135621625;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_YEAR = -2135621624;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_MONTH = -2135621623;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_DAY = -2135621622;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_HOUR = -2135621621;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_MINUTE = -2135621620;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_SECOND = -2135621619;
|
||||
constexpr int32_t SCE_RTC_ERROR_INVALID_MICROSECOND = -2135621618;
|
||||
} // namespace Err
|
253
modules/libSceRtc/entry.cpp
Normal file
253
modules/libSceRtc/entry.cpp
Normal file
@ -0,0 +1,253 @@
|
||||
#include "common.h"
|
||||
#include "logging.h"
|
||||
#include "types.h"
|
||||
|
||||
#include <boost/chrono.hpp>
|
||||
#include <boost/date_time/gregorian/gregorian.hpp>
|
||||
#include <boost/date_time/posix_time/conversion.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <chrono>
|
||||
|
||||
LOG_DEFINE_MODULE(libSceRtc);
|
||||
|
||||
namespace {} // namespace
|
||||
|
||||
extern "C" {
|
||||
|
||||
EXPORT const char* MODULE_NAME = "libSceRtc";
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetCurrentTick(SceRtcTick* pTick) {
|
||||
pTick->tick = boost::chrono::duration_cast<boost::chrono::nanoseconds>(boost::chrono::high_resolution_clock::now().time_since_epoch()).count();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetCurrentClock(SceRtcDateTime* pTime, int iTimeZone) {
|
||||
boost::posix_time::ptime const now = boost::posix_time::microsec_clock::universal_time();
|
||||
|
||||
boost::posix_time::time_duration const duration = now.time_of_day() + boost::posix_time::minutes(iTimeZone);
|
||||
|
||||
pTime->year = now.date().year();
|
||||
pTime->month = now.date().month();
|
||||
pTime->day = now.date().day();
|
||||
pTime->hour = duration.hours();
|
||||
pTime->minute = duration.minutes();
|
||||
pTime->second = duration.seconds();
|
||||
pTime->microsecond = duration.fractional_seconds() * 1000;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetCurrentClockLocalTime(SceRtcDateTime* pTime) {
|
||||
boost::posix_time::ptime const now = boost::posix_time::microsec_clock::local_time();
|
||||
|
||||
boost::posix_time::time_duration const duration = now.time_of_day();
|
||||
|
||||
pTime->year = now.date().year();
|
||||
pTime->month = now.date().month();
|
||||
pTime->day = now.date().day();
|
||||
pTime->hour = duration.hours();
|
||||
pTime->minute = duration.minutes();
|
||||
pTime->second = duration.seconds();
|
||||
pTime->microsecond = duration.fractional_seconds() * 1000;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetCurrentNetworkTick(SceRtcTick* pTick) {
|
||||
pTick->tick = boost::chrono::system_clock::now().time_since_epoch().count();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcConvertUtcToLocalTime(const SceRtcTick* pUtc, SceRtcTick* pLocalTime) {
|
||||
*pLocalTime = *pUtc;
|
||||
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcConvertLocalTimeToUtc(const SceRtcTick* pLocalTime, SceRtcTick* pUtc) {
|
||||
*pUtc = *pLocalTime;
|
||||
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcIsLeapYear(int year) {
|
||||
return boost::gregorian::gregorian_calendar::is_leap_year(2020);
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetDaysInMonth(int year, int month) {
|
||||
return boost::gregorian::gregorian_calendar::end_of_month_day(year, month);
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI SceRTCDay sceRtcGetDayOfWeek(int year, int month, int day) {
|
||||
boost::gregorian::date const date(year, month, day);
|
||||
|
||||
return (SceRTCDay)date.day_of_week().as_number();
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcCheckValid(const SceRtcDateTime* pTime) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcSetTime_t(SceRtcDateTime* pTime, time_t llTime) {
|
||||
boost::posix_time::ptime const ptime = boost::posix_time::from_time_t(llTime);
|
||||
|
||||
auto const date = ptime.date();
|
||||
auto const time = ptime.time_of_day();
|
||||
|
||||
pTime->year = date.year();
|
||||
pTime->month = date.month();
|
||||
pTime->day = date.day();
|
||||
pTime->hour = time.hours();
|
||||
pTime->minute = time.minutes();
|
||||
pTime->second = time.seconds();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetTime_t(const SceRtcDateTime* pTime, time_t* pllTime) {
|
||||
boost::posix_time::ptime ptime(boost::gregorian::date(pTime->year, pTime->month, pTime->day),
|
||||
boost::posix_time::seconds(pTime->hour * 3600 + pTime->minute * 60 + pTime->second));
|
||||
|
||||
*pllTime = boost::posix_time::to_time_t(ptime);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcSetDosTime(SceRtcDateTime* pTime, unsigned int uiDosTime) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetDosTime(const SceRtcDateTime* pTime, unsigned int* puiDosTime) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcSetWin32FileTime(SceRtcDateTime* pTime, uint64_t ulWin32Time) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetWin32FileTime(const SceRtcDateTime* pTime, uint64_t* ulWin32Time) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcSetTick(SceRtcDateTime* pTime, const SceRtcTick* pTick) {
|
||||
boost::posix_time::ptime const ptime = boost::posix_time::from_time_t(pTick->tick);
|
||||
|
||||
auto const date = ptime.date();
|
||||
auto const time = ptime.time_of_day();
|
||||
|
||||
pTime->year = date.year();
|
||||
pTime->month = date.month();
|
||||
pTime->day = date.day();
|
||||
pTime->hour = time.hours();
|
||||
pTime->minute = time.minutes();
|
||||
pTime->second = time.seconds();
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcGetTick(const SceRtcDateTime* pTime, SceRtcTick* pTick) {
|
||||
boost::posix_time::ptime ptime(boost::gregorian::date(pTime->year, pTime->month, pTime->day),
|
||||
boost::posix_time::seconds(pTime->hour * 3600 + pTime->minute * 60 + pTime->second));
|
||||
|
||||
pTick->tick = boost::posix_time::to_time_t(ptime);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI unsigned int sceRtcGetTickResolution(void) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddTicks(SceRtcTick* pTick0, const SceRtcTick* pTick1, int64_t lAdd) {
|
||||
pTick0->tick = pTick1->tick + lAdd;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddMicroseconds(SceRtcTick* pTick0, const SceRtcTick* pTick1, int64_t lAdd) {
|
||||
pTick0->tick = pTick1->tick + lAdd;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddSeconds(SceRtcTick* pTick0, const SceRtcTick* pTick1, int64_t lAdd) {
|
||||
pTick0->tick = uint64_t(1e6) * pTick1->tick + lAdd;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddMinutes(SceRtcTick* pTick0, const SceRtcTick* pTick1, int64_t lAdd) {
|
||||
pTick0->tick = uint64_t(60 * 1e6) * pTick1->tick + lAdd;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddHours(SceRtcTick* pTick0, const SceRtcTick* pTick1, int iAdd) {
|
||||
pTick0->tick = uint64_t(60 * 60 * 1e6) * pTick1->tick + iAdd;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddDays(SceRtcTick* pTick0, const SceRtcTick* pTick1, int iAdd) {
|
||||
pTick0->tick = uint64_t(24 * 60 * 60 * 1e6) * pTick1->tick + iAdd;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddWeeks(SceRtcTick* pTick0, const SceRtcTick* pTick1, int iAdd) {
|
||||
pTick0->tick = uint64_t(7 * 60 * 60 * 1e6) * pTick1->tick + iAdd;
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddMonths(SceRtcTick* pTick0, const SceRtcTick* pTick1, int iAdd) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcTickAddYears(SceRtcTick* pTick0, const SceRtcTick* pTick1, int iAdd) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcFormatRFC2822(char* pszDateTime, const SceRtcTick* pUtc, int iTimeZoneMinutes) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcFormatRFC2822LocalTime(char* pszDateTime, const SceRtcTick* pUtc) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcFormatRFC3339(char* pszDateTime, const SceRtcTick* pUtc, int iTimeZoneMinutes) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcFormatRFC3339LocalTime(char* pszDateTime, const SceRtcTick* pUtc) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcParseDateTime(SceRtcTick* pUtc, const char* pszDateTime) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
|
||||
EXPORT SYSV_ABI int sceRtcParseRFC3339(SceRtcTick* pUtc, const char* pszDateTime) {
|
||||
LOG_USE_MODULE(libSceRtc);
|
||||
LOG_ERR(L"todo %S", __FUNCTION__);
|
||||
return Ok;
|
||||
}
|
||||
}
|
22
modules/libSceRtc/types.h
Normal file
22
modules/libSceRtc/types.h
Normal file
@ -0,0 +1,22 @@
|
||||
#pragma once
|
||||
#include "codes.h"
|
||||
|
||||
enum class SceRTCDay {
|
||||
SUNDAY = 0,
|
||||
MONDAY = 1,
|
||||
TUESDAY = 2,
|
||||
WEDNESDAY = 3,
|
||||
THURSDAY = 4,
|
||||
FRIDAY = 5,
|
||||
SATURDAY = 6,
|
||||
};
|
||||
|
||||
struct SceRtcDateTime {
|
||||
uint16_t year;
|
||||
uint16_t month;
|
||||
uint16_t day;
|
||||
uint16_t hour;
|
||||
uint16_t minute;
|
||||
uint16_t second;
|
||||
uint32_t microsecond;
|
||||
};
|
@ -4,29 +4,29 @@
|
||||
|
||||
namespace Err {
|
||||
|
||||
constexpr int SAVE_DATA_ERROR_PARAMETER = -2137063424; /* 0x809F0000 */
|
||||
constexpr int SAVE_DATA_ERROR_NOT_INITIALIZED = -2137063423; /* 0x809F0001 */
|
||||
constexpr int SAVE_DATA_ERROR_OUT_OF_MEMORY = -2137063422; /* 0x809F0002 */
|
||||
constexpr int SAVE_DATA_ERROR_BUSY = -2137063421; /* 0x809F0003 */
|
||||
constexpr int SAVE_DATA_ERROR_NOT_MOUNTED = -2137063420; /* 0x809F0004 */
|
||||
constexpr int SAVE_DATA_ERROR_NO_PERMISSION = -2137063419; /* 0x809F0005 */
|
||||
constexpr int SAVE_DATA_ERROR_FINGERPRINT_MISMATCH = -2137063418; /* 0x809F0006 */
|
||||
constexpr int SAVE_DATA_ERROR_EXISTS = -2137063417; /* 0x809F0007 */
|
||||
constexpr int SAVE_DATA_ERROR_NOT_FOUND = -2137063416; /* 0x809F0008 */
|
||||
constexpr int SAVE_DATA_ERROR_NO_SPACE_FS = -2137063414; /* 0x809F000A */
|
||||
constexpr int SAVE_DATA_ERROR_INTERNAL = -2137063413; /* 0x809F000B */
|
||||
constexpr int SAVE_DATA_ERROR_MOUNT_FULL = -2137063412; /* 0x809F000C */
|
||||
constexpr int SAVE_DATA_ERROR_BAD_MOUNTED = -2137063411; /* 0x809F000D */
|
||||
constexpr int SAVE_DATA_ERROR_FILE_NOT_FOUND = -2137063410; /* 0x809F000E */
|
||||
constexpr int SAVE_DATA_ERROR_BROKEN = -2137063409; /* 0x809F000F */
|
||||
constexpr int SAVE_DATA_ERROR_INVALID_LOGIN_USER = -2137063407; /* 0x809F0011 */
|
||||
constexpr int SAVE_DATA_ERROR_MEMORY_NOT_READY = -2137063406; /* 0x809F0012 */
|
||||
constexpr int SAVE_DATA_ERROR_BACKUP_BUSY = -2137063405; /* 0x809F0013 */
|
||||
constexpr int SAVE_DATA_ERROR_NOT_REGIST_CALLBACK = -2137063403; /* 0x809F0015 */
|
||||
constexpr int SAVE_DATA_ERROR_BUSY_FOR_SAVING = -2137063402; /* 0x809F0016 */
|
||||
constexpr int SAVE_DATA_ERROR_LIMITATION_OVER = -2137063401; /* 0x809F0017 */
|
||||
constexpr int SAVE_DATA_ERROR_EVENT_BUSY = -2137063400; /* 0x809F0018 */
|
||||
constexpr int SAVE_DATA_ERROR_PARAMSFO_TRANSFER_TITLE_ID_NOT_FOUND = -2137063399; /* 0x809F0019 */
|
||||
constexpr int SAVE_DATA_ERROR_PARAMETER = -2137063424;
|
||||
constexpr int SAVE_DATA_ERROR_NOT_INITIALIZED = -2137063423;
|
||||
constexpr int SAVE_DATA_ERROR_OUT_OF_MEMORY = -2137063422;
|
||||
constexpr int SAVE_DATA_ERROR_BUSY = -2137063421;
|
||||
constexpr int SAVE_DATA_ERROR_NOT_MOUNTED = -2137063420;
|
||||
constexpr int SAVE_DATA_ERROR_NO_PERMISSION = -2137063419;
|
||||
constexpr int SAVE_DATA_ERROR_FINGERPRINT_MISMATCH = -2137063418;
|
||||
constexpr int SAVE_DATA_ERROR_EXISTS = -2137063417;
|
||||
constexpr int SAVE_DATA_ERROR_NOT_FOUND = -2137063416;
|
||||
constexpr int SAVE_DATA_ERROR_NO_SPACE_FS = -2137063414;
|
||||
constexpr int SAVE_DATA_ERROR_INTERNAL = -2137063413;
|
||||
constexpr int SAVE_DATA_ERROR_MOUNT_FULL = -2137063412;
|
||||
constexpr int SAVE_DATA_ERROR_BAD_MOUNTED = -2137063411;
|
||||
constexpr int SAVE_DATA_ERROR_FILE_NOT_FOUND = -2137063410;
|
||||
constexpr int SAVE_DATA_ERROR_BROKEN = -2137063409;
|
||||
constexpr int SAVE_DATA_ERROR_INVALID_LOGIN_USER = -2137063407;
|
||||
constexpr int SAVE_DATA_ERROR_MEMORY_NOT_READY = -2137063406;
|
||||
constexpr int SAVE_DATA_ERROR_BACKUP_BUSY = -2137063405;
|
||||
constexpr int SAVE_DATA_ERROR_NOT_REGIST_CALLBACK = -2137063403;
|
||||
constexpr int SAVE_DATA_ERROR_BUSY_FOR_SAVING = -2137063402;
|
||||
constexpr int SAVE_DATA_ERROR_LIMITATION_OVER = -2137063401;
|
||||
constexpr int SAVE_DATA_ERROR_EVENT_BUSY = -2137063400;
|
||||
constexpr int SAVE_DATA_ERROR_PARAMSFO_TRANSFER_TITLE_ID_NOT_FOUND = -2137063399;
|
||||
|
||||
} // namespace Err
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user