Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKacper Michajłow <kasper93@gmail.com>2016-04-16 23:35:07 +0300
committerKacper Michajłow <kasper93@gmail.com>2016-04-17 22:07:46 +0300
commit1aef38f954e482279f786406b93d168473e79b15 (patch)
tree73949f8130c08017908780f2703961cfffb0f295
parent7797ce653d2ed3981e0f4dafd27f22ae66fa1ab4 (diff)
CPixelShaderCache: Do not create empty directory if cache is disabled.
Also remove directory if it existed.
-rw-r--r--src/filters/renderer/VideoRenderers/PixelShaderCache.cpp23
-rw-r--r--src/filters/renderer/VideoRenderers/PixelShaderCache.h6
2 files changed, 14 insertions, 15 deletions
diff --git a/src/filters/renderer/VideoRenderers/PixelShaderCache.cpp b/src/filters/renderer/VideoRenderers/PixelShaderCache.cpp
index e2c9debed..c8975f0f2 100644
--- a/src/filters/renderer/VideoRenderers/PixelShaderCache.cpp
+++ b/src/filters/renderer/VideoRenderers/PixelShaderCache.cpp
@@ -126,19 +126,18 @@ void CPixelShaderCache::DestroyCache()
{
CString cacheFolder;
if (GetCacheFolder(cacheFolder)) {
- CFileFind finder;
- BOOL working = finder.FindFile(cacheFolder + _T("\\*"));
-
- while (working) {
- working = finder.FindNextFile();
- if (!finder.IsDirectory() && !finder.IsDots()) {
- CFile::Remove(finder.GetFilePath());
- }
- }
+ SHFILEOPSTRUCT fileop = {};
+ fileop.wFunc = FO_DELETE;
+ // The last file name is terminated with a double NULL character ("\0\0") to indicate the end of the buffer.
+ // We add one char to CString. GetBufferSetLength adds NULL at the end and since previous end was also NULL
+ // returned buffer have double NULL character at the end in result.
+ fileop.pFrom = cacheFolder.GetBufferSetLength(cacheFolder.GetLength() + 1);
+ fileop.fFlags = FOF_NOCONFIRMATION | FOF_SILENT;
+ VERIFY(SHFileOperation(&fileop) == 0);
}
}
-bool CPixelShaderCache::IsEnabled() const
+bool CPixelShaderCache::IsEnabled()
{
return GetRenderersSettings().m_AdvRendSets.bCacheShaders;
}
@@ -217,11 +216,11 @@ bool CPixelShaderCache::GetCacheFilePath(CString& CacheFilePath, uint64_t Hash)
return false;
}
-bool CPixelShaderCache::GetCacheFolder(CString& CacheFolder) const
+bool CPixelShaderCache::GetCacheFolder(CString& CacheFolder)
{
CacheFolder = GetRenderersSettings().m_AdvRendSets.sShaderCachePath;
- return CacheFolder.GetLength() > 0 && (PathFileExists(CacheFolder) || CreateDirectory(CacheFolder, nullptr));
+ return !CacheFolder.IsEmpty() && (PathFileExists(CacheFolder) || (IsEnabled() && CreateDirectory(CacheFolder, nullptr)));
}
uint64_t CPixelShaderCache::Hash(LPCSTR pProfile, LPCSTR pSourceData, SIZE_T SourceDataSize) const
diff --git a/src/filters/renderer/VideoRenderers/PixelShaderCache.h b/src/filters/renderer/VideoRenderers/PixelShaderCache.h
index 7e7bc7e3e..b7160955c 100644
--- a/src/filters/renderer/VideoRenderers/PixelShaderCache.h
+++ b/src/filters/renderer/VideoRenderers/PixelShaderCache.h
@@ -52,14 +52,14 @@ public:
private:
void LoadCache();
- void DestroyCache();
- bool IsEnabled() const;
+ static void DestroyCache();
+ static bool IsEnabled();
void TouchFile(const CString& FileName) const;
bool IsFileOutdated(const CString& FileName) const;
bool LoadCache(const CString& FileName, const CString& FilePath);
void DeleteCache(uint64_t Hash);
bool GetCacheFilePath(CString& CacheFilePath, uint64_t Hash) const;
- bool GetCacheFolder(CString& CacheFolder) const;
+ static bool GetCacheFolder(CString& CacheFolder);
uint64_t Hash(LPCSTR pProfile, LPCSTR pSourceData, SIZE_T SourceDataSize) const;
uint64_t Hash(LPCSTR pStr) const;