// TODO: create in TEMP directory instead? static WCHAR *GetThumbnailPath(const WCHAR *filePath) { // create a fingerprint of a (normalized) path for the file name // I'd have liked to also include the file's last modification time // in the fingerprint (much quicker than hashing the entire file's // content), but that's too expensive for files on slow drives unsigned char digest[16]; ScopedMem<char> pathU(str::conv::ToUtf8(filePath)); if (path::HasVariableDriveLetter(filePath)) pathU[0] = '?'; // ignore the drive letter, if it might change CalcMD5Digest((unsigned char *)pathU.Get(), str::Len(pathU), digest); ScopedMem<char> fingerPrint(str::MemToHex(digest, 16)); ScopedMem<WCHAR> thumbsPath(AppGenDataFilename(THUMBNAILS_DIR_NAME)); if (!thumbsPath) return NULL; ScopedMem<WCHAR> fname(str::conv::FromAnsi(fingerPrint)); return str::Format(L"%s\\%s.png", thumbsPath, fname); }
// TODO: create in TEMP directory instead? static WCHAR* GetThumbnailPath(const WCHAR* filePath) { // create a fingerprint of a (normalized) path for the file name // I'd have liked to also include the file's last modification time // in the fingerprint (much quicker than hashing the entire file's // content), but that's too expensive for files on slow drives unsigned char digest[16]; // TODO: why is this happening? Seen in crash reports e.g. 35043 if (!filePath) return nullptr; OwnedData pathU(str::conv::ToUtf8(filePath)); if (!pathU.Get()) return nullptr; if (path::HasVariableDriveLetter(filePath)) pathU.Get()[0] = '?'; // ignore the drive letter, if it might change CalcMD5Digest((unsigned char*)pathU.Get(), str::Len(pathU.Get()), digest); AutoFree fingerPrint(_MemToHex(&digest)); AutoFreeW thumbsPath(AppGenDataFilename(THUMBNAILS_DIR_NAME)); if (!thumbsPath) return nullptr; AutoFreeW fname(str::conv::FromAnsi(fingerPrint)); return str::Format(L"%s\\%s.png", thumbsPath.Get(), fname.Get()); }