mirror of https://github.com/PCSX2/pcsx2.git
FolderMemoryCard: Correctly write the internal memory card file creation/modification timestamps to the host file system's file attributes.
This commit is contained in:
parent
cb01523677
commit
7a388c73c5
|
@ -1410,6 +1410,17 @@ wxFFile* FileAccessHelper::ReOpen( const wxFileName& folderName, MemoryCardFileM
|
|||
}
|
||||
}
|
||||
|
||||
void FileAccessHelper::CloseFileHandle( wxFFile* file, const MemoryCardFileEntry* entry ) {
|
||||
file->Close();
|
||||
|
||||
if ( entry != nullptr ) {
|
||||
wxFileName fn( file->GetName() );
|
||||
fn.SetTimes( nullptr, &entry->entry.data.timeModified.ToWxDateTime(), &entry->entry.data.timeCreated.ToWxDateTime() );
|
||||
}
|
||||
|
||||
delete file;
|
||||
}
|
||||
|
||||
void FileAccessHelper::CloseMatching( const wxString& path ) {
|
||||
wxFileName fn( path );
|
||||
fn.Normalize();
|
||||
|
@ -1417,8 +1428,7 @@ void FileAccessHelper::CloseMatching( const wxString& path ) {
|
|||
for ( auto it = m_files.begin(); it != m_files.end(); ) {
|
||||
wxString openPath = it->second->GetName();
|
||||
if ( openPath.StartsWith( pathNormalized ) ) {
|
||||
it->second->Close();
|
||||
delete it->second;
|
||||
CloseFileHandle( it->second, it->first );
|
||||
it = m_files.erase( it );
|
||||
} else {
|
||||
++it;
|
||||
|
@ -1428,8 +1438,7 @@ void FileAccessHelper::CloseMatching( const wxString& path ) {
|
|||
|
||||
void FileAccessHelper::CloseAll() {
|
||||
for ( auto it = m_files.begin(); it != m_files.end(); ++it ) {
|
||||
it->second->Close();
|
||||
delete it->second;
|
||||
CloseFileHandle( it->second, it->first );
|
||||
}
|
||||
m_files.clear();
|
||||
}
|
||||
|
|
|
@ -85,6 +85,19 @@ struct MemoryCardFileEntryDateTime {
|
|||
return t;
|
||||
}
|
||||
|
||||
wxDateTime ToWxDateTime() const {
|
||||
wxDateTime::Tm tm;
|
||||
tm.sec = this->second;
|
||||
tm.min = this->minute;
|
||||
tm.hour = this->hour;
|
||||
tm.mday = this->day;
|
||||
tm.mon = (wxDateTime::Month)(this->month - 1);
|
||||
tm.year = this->year;
|
||||
|
||||
wxDateTime time( tm );
|
||||
return time.FromTimezone( wxDateTime::GMT9 );
|
||||
}
|
||||
|
||||
bool operator==( const MemoryCardFileEntryDateTime& other ) const {
|
||||
return unused == other.unused && second == other.second && minute == other.minute && hour == other.hour
|
||||
&& day == other.day && month == other.month && year == other.year;
|
||||
|
@ -210,6 +223,9 @@ public:
|
|||
protected:
|
||||
// Open a new file and remember it for later
|
||||
wxFFile* Open( const wxFileName& folderName, MemoryCardFileMetadataReference* fileRef, bool writeMetadata = false );
|
||||
// Close a file and delete its handle
|
||||
// If entry is given, it also attempts to set the created and modified timestamps of the file according to the entry
|
||||
void CloseFileHandle( wxFFile* file, const MemoryCardFileEntry* entry = nullptr );
|
||||
|
||||
void WriteMetadata( const wxFileName& folderName, MemoryCardFileMetadataReference* fileRef );
|
||||
void WriteMetadata( bool metadataIsNonstandard, const wxFileName& metadataFilename, const MemoryCardFileEntry* const entry );
|
||||
|
|
Loading…
Reference in New Issue