diff --git a/VGMPlay/VGMPlay_Updates.txt b/VGMPlay/VGMPlay_Updates.txt index 5f043b5..d5617c3 100644 --- a/VGMPlay/VGMPlay_Updates.txt +++ b/VGMPlay/VGMPlay_Updates.txt @@ -170,3 +170,4 @@ Updates since 0.4.0u8 (16.04.2017) - fixed SN76496 variant being incorrectly called NCR7496 instead of NCR8496 - [in_vgm] made "Tag fallback" option work (finally, after 5 years!) - [in_vgm] made "disable file information cache" option selectable via configuration +- [in_vgm] fix VGM information dialog using cached data even if file was changed diff --git a/in_vgm/dlg_fileinfo.c b/in_vgm/dlg_fileinfo.c index 6111eb9..59fa057 100644 --- a/in_vgm/dlg_fileinfo.c +++ b/in_vgm/dlg_fileinfo.c @@ -25,6 +25,7 @@ typedef struct fileinfo_data wchar_t* FileName; bool ForceReload; + FILETIME FileTime; UINT32 FileSize; VGM_HEADER Head; GD3_TAG Tag; @@ -238,14 +239,33 @@ static bool LoadInfoA(const char* FileName, FINF_DATA* FileInf) static bool LoadInfoW(const wchar_t* FileName, FINF_DATA* FileInf) { + HANDLE hFile; + FILETIME fileWrtTime; VGM_HEADER* FH; UINT32 StrSize; INT32 TempSLng; + hFile = CreateFileW(FileName, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, 0, NULL); + if (hFile != INVALID_HANDLE_VALUE) + { + GetFileTime(hFile, NULL, NULL, &fileWrtTime); + CloseHandle(hFile); hFile = NULL; + } + else + { + fileWrtTime.dwLowDateTime = 0x00; + fileWrtTime.dwHighDateTime = 0x00; + } + if (! FileInf->ForceReload && ! Options.NoInfoCache) { if (FileInf->FileName != NULL && ! _wcsicmp(FileInf->FileName, FileName)) - return true; // I just loaded that file. + { + // We just loaded that file. + if (CompareFileTime(&fileWrtTime, &FileInf->FileTime) == 0) + return true; // The file wasn't changed, so don't reload. + } } FileInf->ForceReload = false; @@ -268,6 +288,7 @@ static bool LoadInfoW(const wchar_t* FileName, FINF_DATA* FileInf) // copy all info from PlayVGMInfo to current structure // (advanced caching) ;) + FileInf->FileTime = PlayVGMInfo.FileTime; FileInf->FileSize = PlayVGMInfo.FileSize; FileInf->Head = PlayVGMInfo.Head; CopyTagData(&FileInf->Tag, &PlayVGMInfo.Tag); @@ -292,6 +313,8 @@ static bool LoadInfoW(const wchar_t* FileName, FINF_DATA* FileInf) if (! FileInf->FileSize) { + FileInf->FileTime.dwLowDateTime = 0x00; + FileInf->FileTime.dwHighDateTime = 0x00; FileInf->FileSize = 0x00; memset(&FileInf->Head, 0x00, sizeof(VGM_HEADER)); memset(&FileInf->Tag, 0x00, sizeof(GD3_TAG)); @@ -310,6 +333,7 @@ static bool LoadInfoW(const wchar_t* FileName, FINF_DATA* FileInf) wcscpy(FileInf->Tag.strNotes, L"File invalid!"); return false; } + FileInf->FileTime = fileWrtTime; FH = &FileInf->Head; FileInf->TrackLen = CalcSampleMSecExt(FH->lngTotalSamples, 0x02, FH);