// Shave and a Haircut // (c) 2019 Epic Games // US Patent 6720962 #ifndef OSMac_ #include #else #include "shaveMacCarbon.h" #endif #include #ifndef _WIN32 #include #endif #include #include #include #include "shaveIcon.h" MStringArray shaveIcon::mIcons; MIntArray shaveIcon::mTimestamps; // // See header file for documentation. // bool shaveIcon::needsReload(MString iconFile) { #ifdef _WIN32 struct _stat fileInfo; bool fileExists = (_stat(iconFile.asChar(), &fileInfo) == 0); #else struct stat fileInfo; # if defined(OSMac_) && !defined(OSMac_MachO_) MString hfsFileName = shaveMacCarbon::makeMacFilename(iconFile); bool fileExists = (stat(hfsFileName.asChar(), &fileInfo) == 0); #else bool fileExists = (stat(iconFile.asChar(), &fileInfo) == 0); # endif #endif bool reload = false; unsigned int i; unsigned int numEntries = mIcons.length(); for (i = 0; i < numEntries; i++) if (mIcons[i] == iconFile) break; if (fileExists) { if (i == numEntries) { // // New icon. // mIcons.append(iconFile); mTimestamps.append((long)fileInfo.st_mtime); } else { if (fileInfo.st_mtime != mTimestamps[i]) { // // File has been modified since we last saw it, so update // its timestamp and force a reload. // mTimestamps[i] = (long)fileInfo.st_mtime; reload = true; } } } else { if (i < numEntries) { // // This file used to exist, but no longer does, so force a // reload and reset the timestamp to zero so that if it shows // up again, we'll force another reload. // reload = true; mTimestamps[i] = 0L; } } return reload; } void shaveIcon::cleanup() { mIcons.clear(); mTimestamps.clear(); }