// generate config file path static void get_config_path(wxPathList &path, bool exists = true) { // local config dir first, then global // locale-specific res first, then main wxStandardPathsBase &stdp = wxStandardPaths::Get(); #define add_path(p) do { \ const wxString& s = stdp.p; \ wxFileName parent = wxFileName::DirName(s + wxT("//..")); \ parent.MakeAbsolute(); \ if((wxDirExists(s) && wxIsWritable(s)) || ((!exists || !wxDirExists(s)) && parent.IsDirWritable())) \ path.Add(s); \ } while(0) // NOTE: this does not support XDG (freedesktop.org) paths add_path(GetUserLocalDataDir()); add_path(GetUserDataDir()); add_path(GetLocalizedResourcesDir(wxGetApp().locale.GetCanonicalName())); add_path(GetResourcesDir()); add_path(GetDataDir()); add_path(GetLocalDataDir()); add_path(GetPluginsDir()); }
Logger::Logger() : bMutedAll(FALSE), bOnTop(TRUE), bToWindow(TRUE), bToConsole(FALSE), bToFile(FALSE), bSPALID(FALSE) { if(0 != GetPluginsDir(szFile, sizeof(szFile))) { strcat(szFile, DIR_SEPARATOR); strcat(szFile, DEFAULT_LOG_FILE_NAME); } else szFile[0] = '\0'; for(int i = 0; i < sizeof(bMutedCalls)/sizeof(BOOL); i++) bMutedCalls[i] = FALSE; bMutedCalls[action_npn_mem_alloc] = TRUE; bMutedCalls[action_npn_mem_free] = TRUE; bMutedCalls[action_npn_mem_flush] = TRUE; }
QString FindPluginName(const QString &plugname) { return GetPluginsDir() + kPluginLibPrefix + plugname + kPluginLibSuffix; }
XP_HLIB LoadRealPlugin(char * mimetype) { if(!mimetype || !strlen(mimetype)) return NULL; #ifdef XP_WIN BOOL bDone = FALSE; WIN32_FIND_DATA ffdataStruct; char szPath[_MAX_PATH]; char szFileName[_MAX_PATH]; // DebugBreak(); GetPluginsDir(szPath, _MAX_PATH); if(logger) { char msg[512]; sprintf(msg, "LoadRealPlugin Path: %s\r\n", szPath); logger->logMessage(msg); } strcpy(szFileName, szPath); std::vector<std::string> directories; directories.push_back(szFileName); directories.push_back("C:\\Windows\\System32\\Macromed\\Flash"); directories.push_back("C:\\Windows\\SysWOW64\\Macromed\\Flash"); for (size_t i = 0; i < directories.size(); ++i) { std::string search_path = directories[i]; search_path = search_path.append("\\np*.dll"); HANDLE handle = FindFirstFile(search_path.c_str(), &ffdataStruct); if(handle == INVALID_HANDLE_VALUE) { FindClose(handle); continue; } DWORD versize = 0L; DWORD zero = 0L; char * verbuf = NULL; do { std::string cur_file = directories[i]; cur_file = cur_file.append("\\"); cur_file = cur_file.append(ffdataStruct.cFileName); if(!(ffdataStruct. dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && strstr(cur_file.c_str(), "npspy.dll") == NULL) { versize = GetFileVersionInfoSize(cur_file.c_str(), &zero); if (versize > 0) verbuf = new char[versize]; else continue; if(!verbuf) continue; GetFileVersionInfo(cur_file.c_str(), NULL, versize, verbuf); char *mimetypes = NULL; UINT len = 0; if(!VerQueryValue(verbuf, "\\StringFileInfo\\040904E4\\MIMEType", (void **)&mimetypes, &len) || !mimetypes || !len) { delete [] verbuf; continue; } // browse through a string of mimetypes mimetypes[len] = '\0'; char * type = mimetypes; BOOL more = TRUE; while(more) { char * p = strchr(type, '|'); if(p) *p = '\0'; else more = FALSE; if(0 == _stricmp(mimetype, type)) { // this is it! delete [] verbuf; FindClose(handle); HINSTANCE hLib = LoadLibrary(cur_file.c_str()); return hLib; } type = p; type++; } delete [] verbuf; } } while(FindNextFile(handle, &ffdataStruct)); FindClose(handle); } #endif #ifdef XP_UNIX // Implement UNIX version #endif #ifdef XP_MAC // Implement Mac version #endif return NULL; }