// create a new phrase list. check dates on top-level list files to see if a reload is necessary. // note: unlike above, doesn't automatically call readPhraseList. // pass in exception, banned, and weighted phrase lists all at once. int ListManager::newPhraseList(const char *exception, const char *banned, const char *weighted) { time_t bannedpfiledate = getFileDate(banned); time_t exceptionpfiledate = getFileDate(exception); time_t weightedpfiledate = getFileDate(weighted); for (size_t i = 0; i < l.size(); i++) { if (l[i] == NULL) { continue; } if ((*l[i]).exceptionpfile == String(exception) && (*l[i]).bannedpfile == String(banned) && (*l[i]).weightedpfile == String(weighted)) { if (bannedpfiledate <= (*l[i]).bannedpfiledate && exceptionpfiledate <= (*l[i]).exceptionpfiledate && weightedpfiledate <= (*l[i]).weightedpfiledate) { // Known limitation - only weighted, exception, banned phrase // list checked for changes - not the included files. // //need to check all files that were included for phrase list //so when phrases read in in list container it needs to store //all the file names and if a single one has changed needs a //complete regenerate #ifdef DGDEBUG std::cout << "Using previous phrase: " << exception << " - " << banned << " - " << weighted << std::endl; #endif refList(i); return i; } } } int free = findNULL(); if (free > -1) { l[(unsigned) free] = new ListContainer; } else { l.push_back(new ListContainer); free = l.size() - 1; } (*l[(unsigned) free]).parent = true; // all phrase lists are parent as // there are no sub lists (*l[(unsigned) free]).bannedpfiledate = bannedpfiledate; (*l[(unsigned) free]).exceptionpfiledate = exceptionpfiledate; (*l[(unsigned) free]).weightedpfiledate = weightedpfiledate; (*l[(unsigned) free]).exceptionpfile = exception; (*l[(unsigned) free]).bannedpfile = banned; (*l[(unsigned) free]).weightedpfile = weighted; return (unsigned) free; }
std::string GpuCapabilitiesWindows::getDriverDate() { LDEBUG("Retrieving driver date ..."); if ( getVendor() == GPU_VENDOR_NVIDIA ) { LDEBUG("Retrieving driver date by querying file date of NVIDIA driver dll ..."); std::string result; //TODO: windows vista stores the name of the dll in the registry. // its better to get the name from there (cdoer) if (getOSVersion() == OS_WIN_VISTA) result = getFileDate("nvoglv32.dll"); else result = getFileDate(DRIVER_DLL_NVIDIA); if (result.length() == 0) { LDEBUG("Failed reading driver date from NVIDIA driver dll."); } else { LDEBUG("Reading driver date successful."); return result; } } else if (getVendor() == GPU_VENDOR_ATI) { LDEBUG("Retrieving driver date by querying file date of ATI driver dll ..."); std::string result = getFileDate(DRIVER_DLL_ATI); if (result.length() == 0) { LDEBUG("Failed reading driver date from ATI driver dll."); } else { LDEBUG("Reading driver date successful."); return result; } } #ifdef CGT_WITH_WMI // unknown vendor or reading driver date from vendor dll failed: // read driver date from WMI LDEBUG("Reading driver date from WMI ..."); if (isWMIinited()) { // Win32_VideoController class: http://msdn2.microsoft.com/en-us/library/aa394512.aspx std::string date = WMIqueryStr("Win32_VideoController", "DriverDate"); if (date.length() > 0) { LDEBUG("Reading driver date successful."); // convert to yyyy-mm-dd format. // see http://msdn2.microsoft.com/en-us/library/aa387237.aspx for specification of CIM_DATETIME std::string dateformat = ""; dateformat.append(date.substr(0,4)); dateformat.append("-"); dateformat.append(date.substr(4,2)); dateformat.append("-"); dateformat.append(date.substr(6,2)); return dateformat; } else { LDEBUG("Failed reading driver date."); LWARNING("Failed to detect driver date"); return ""; } } else { LDEBUG("Unable to read DriverDate from WMI: not inited"); } #else LDEBUG("Compiled without WMI support."); LWARNING("Failed to detect driver date"); #endif return ""; }