mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-07-11 01:25:07 +02:00
sceIo: Add support for microseconds in filetimes (not implemented in platforms yet)
This commit is contained in:
@@ -11,17 +11,23 @@
|
||||
namespace File {
|
||||
|
||||
struct FileInfo {
|
||||
std::string name;
|
||||
std::string name; // local name in directory
|
||||
Path fullName;
|
||||
|
||||
bool exists = false;
|
||||
bool isDirectory = false;
|
||||
bool isWritable = false;
|
||||
uint64_t size = 0;
|
||||
|
||||
uint64_t size = 0; // in bytes
|
||||
|
||||
// time_t
|
||||
uint64_t atime = 0;
|
||||
uint64_t mtime = 0;
|
||||
uint64_t ctime = 0;
|
||||
// Microseconds, addition to the time_t.
|
||||
int atimeUs = 0;
|
||||
int mtimeUs = 0;
|
||||
int ctimeUs = 0;
|
||||
// Access bitfield
|
||||
uint32_t access = 0; // st_mode & 0x1ff
|
||||
|
||||
bool operator <(const FileInfo &other) const;
|
||||
|
||||
@@ -1236,14 +1236,16 @@ bool SavedataParam::GetList(SceUtilitySavedataParam *param)
|
||||
{
|
||||
entries[i].st_mode = 0x11FF;
|
||||
if (sfoFiles[i].exists) {
|
||||
__IoCopyDate(entries[i].st_ctime, sfoFiles[i].ctime);
|
||||
__IoCopyDate(entries[i].st_atime, sfoFiles[i].atime);
|
||||
__IoCopyDate(entries[i].st_mtime, sfoFiles[i].mtime);
|
||||
ConvertTmToPspDateTime(entries[i].st_ctime, sfoFiles[i].ctime, sfoFiles[i].ctimeUs);
|
||||
ConvertTmToPspDateTime(entries[i].st_atime, sfoFiles[i].atime, sfoFiles[i].atimeUs);
|
||||
ConvertTmToPspDateTime(entries[i].st_mtime, sfoFiles[i].mtime, sfoFiles[i].mtimeUs);
|
||||
} else {
|
||||
__IoCopyDate(entries[i].st_ctime, validDir[i].ctime);
|
||||
__IoCopyDate(entries[i].st_atime, validDir[i].atime);
|
||||
__IoCopyDate(entries[i].st_mtime, validDir[i].mtime);
|
||||
// What?
|
||||
ConvertTmToPspDateTime(entries[i].st_ctime, validDir[i].ctime, validDir[i].ctimeUs);
|
||||
ConvertTmToPspDateTime(entries[i].st_atime, validDir[i].atime, validDir[i].atimeUs);
|
||||
ConvertTmToPspDateTime(entries[i].st_mtime, validDir[i].mtime, validDir[i].mtimeUs);
|
||||
}
|
||||
|
||||
// folder name without gamename (max 20 u8)
|
||||
std::string outName = validDir[i].name.substr(GetGameName(param).size());
|
||||
memset(entries[i].name, 0, sizeof(entries[i].name));
|
||||
@@ -1364,9 +1366,9 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param, u32 requestAddr)
|
||||
|
||||
entry->st_mode = 0x21FF;
|
||||
entry->st_size = file->size + sizeOffset;
|
||||
__IoCopyDate(entry->st_ctime, file->ctime);
|
||||
__IoCopyDate(entry->st_atime, file->atime);
|
||||
__IoCopyDate(entry->st_mtime, file->mtime);
|
||||
ConvertTmToPspDateTime(entry->st_ctime, file->ctime, file->ctimeUs);
|
||||
ConvertTmToPspDateTime(entry->st_atime, file->atime, file->atimeUs);
|
||||
ConvertTmToPspDateTime(entry->st_mtime, file->mtime, file->mtimeUs);
|
||||
// TODO: Probably actually 13 + 3 pad...
|
||||
strncpy(entry->name, file->name.c_str(), 16);
|
||||
entry->name[15] = '\0';
|
||||
@@ -1467,14 +1469,12 @@ bool SavedataParam::GetSize(SceUtilitySavedataParam *param) {
|
||||
return exists;
|
||||
}
|
||||
|
||||
void SavedataParam::Clear()
|
||||
{
|
||||
if (saveDataList)
|
||||
{
|
||||
for (int i = 0; i < saveNameListDataCount; i++)
|
||||
{
|
||||
if (saveDataList[i].texture != NULL && (!noSaveIcon || saveDataList[i].texture != noSaveIcon->texture))
|
||||
void SavedataParam::Clear() {
|
||||
if (saveDataList) {
|
||||
for (int i = 0; i < saveNameListDataCount; i++) {
|
||||
if (saveDataList[i].texture && (!noSaveIcon || saveDataList[i].texture != noSaveIcon->texture)) {
|
||||
delete saveDataList[i].texture;
|
||||
}
|
||||
saveDataList[i].texture = NULL;
|
||||
}
|
||||
|
||||
@@ -1491,8 +1491,7 @@ void SavedataParam::Clear()
|
||||
}
|
||||
}
|
||||
|
||||
int SavedataParam::SetPspParam(SceUtilitySavedataParam *param)
|
||||
{
|
||||
int SavedataParam::SetPspParam(SceUtilitySavedataParam *param) {
|
||||
pspParam = param;
|
||||
if (!pspParam) {
|
||||
Clear();
|
||||
|
||||
@@ -776,6 +776,10 @@ PSPFileInfo DirectoryFileSystem::GetFileInfo(std::string filename) {
|
||||
localtime_r((time_t*)&ctime, &x.ctime);
|
||||
localtime_r((time_t*)&mtime, &x.mtime);
|
||||
|
||||
x.atimeUs = info.atimeUs;
|
||||
x.ctimeUs = info.ctimeUs;
|
||||
x.mtimeUs = info.mtimeUs;
|
||||
|
||||
return ReplayApplyDiskFileInfo(x, CoreTiming::GetGlobalTimeUs());
|
||||
}
|
||||
|
||||
|
||||
@@ -118,9 +118,9 @@ struct PSPFileInfo {
|
||||
bool exists = false;
|
||||
FileType type = FILETYPE_NORMAL;
|
||||
|
||||
tm atime{};
|
||||
tm ctime{};
|
||||
tm mtime{};
|
||||
tm atime{}; int atimeUs = 0;
|
||||
tm ctime{}; int ctimeUs = 0;
|
||||
tm mtime{}; int mtimeUs = 0;
|
||||
|
||||
bool isOnSectorSystem = false;
|
||||
u32 startSector = 0;
|
||||
|
||||
+8
-9
@@ -905,18 +905,17 @@ u64 __IoCompleteAsyncIO(FileNode *f) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __IoCopyDate(ScePspDateTime& date_out, const tm& date_in)
|
||||
{
|
||||
date_out.year = date_in.tm_year+1900;
|
||||
date_out.month = date_in.tm_mon+1;
|
||||
void ConvertTmToPspDateTime(ScePspDateTime& date_out, const tm& date_in, int microSeconds) {
|
||||
date_out.year = date_in.tm_year + 1900;
|
||||
date_out.month = date_in.tm_mon + 1;
|
||||
date_out.day = date_in.tm_mday;
|
||||
date_out.hour = date_in.tm_hour;
|
||||
date_out.minute = date_in.tm_min;
|
||||
date_out.second = date_in.tm_sec;
|
||||
date_out.microsecond = 0;
|
||||
date_out.microsecond = microSeconds;
|
||||
}
|
||||
|
||||
static void __IoGetStat(SceIoStat *stat, PSPFileInfo &info) {
|
||||
static void __IoGetStat(SceIoStat *stat, const PSPFileInfo &info) {
|
||||
memset(stat, 0xfe, sizeof(SceIoStat));
|
||||
|
||||
int type, attr;
|
||||
@@ -931,9 +930,9 @@ static void __IoGetStat(SceIoStat *stat, PSPFileInfo &info) {
|
||||
stat->st_mode = type | info.access;
|
||||
stat->st_attr = attr;
|
||||
stat->st_size = info.size;
|
||||
__IoCopyDate(stat->st_a_time, info.atime);
|
||||
__IoCopyDate(stat->st_c_time, info.ctime);
|
||||
__IoCopyDate(stat->st_m_time, info.mtime);
|
||||
ConvertTmToPspDateTime(stat->st_a_time, info.atime, info.atimeUs);
|
||||
ConvertTmToPspDateTime(stat->st_c_time, info.ctime, info.ctimeUs);
|
||||
ConvertTmToPspDateTime(stat->st_m_time, info.mtime, info.mtimeUs);
|
||||
stat->st_private[0] = info.startSector;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ u32 sceIoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 ou
|
||||
int __IoIoctl(u32 id, u32 cmd, u32 indataPtr, u32 inlen, u32 outdataPtr, u32 outlen, int &usec);
|
||||
|
||||
u32 __IoGetFileHandleFromId(u32 id, u32 &outError);
|
||||
void __IoCopyDate(ScePspDateTime& date_out, const tm& date_in);
|
||||
void ConvertTmToPspDateTime(ScePspDateTime& date_out, const tm& date_in, int microSeconds);
|
||||
|
||||
KernelObject *__KernelFileNodeObject();
|
||||
KernelObject *__KernelDirListingObject();
|
||||
|
||||
Reference in New Issue
Block a user