MistString Path::GetResource() { #if defined(MIST_OS_WINDOWS) return L"./"; #elif defined(MIST_OS_OSX) return GetApplicationPath() + L"/Contents/Resources/"; #elif defined(MIST_OS_IOS) return GetApplicationPath() + L"/"; #elif defined(MIST_OS_FAMILY_UNIX) return L"./"; #endif }
void Unpack(const string& dir) { int offset = GetPackageDataOffset(); int size = GetPackageDataSize(); int buf_size = min(size, 0x200000); char* buf = new char[buf_size]; string app_path = GetApplicationPath(); HANDLE file_handle = CreateFile(app_path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); SetFilePointer(file_handle, offset, 0, FILE_BEGIN); DWORD bytes_read = buf_size; do { ReadFile(file_handle, buf, buf_size, &bytes_read, NULL); if (bytes_read > 0) { } } while (bytes_read == buf_size); CloseHandle(file_handle); delete[] buf; }
void FileContextMenuExt::OnVerbThroughItem(HWND hWnd) { wchar_t szMessage[2000]; if (SUCCEEDED(StringCchPrintf(szMessage, ARRAYSIZE(szMessage),L"-Shred_Through \"%s\"", getSelectedNames().c_str()))) { ShellExecute( NULL, L"open", GetApplicationPath().c_str(), szMessage, NULL, SW_SHOWNORMAL ); } }
static void BuildIWADDirList(void) { char *doomwaddir; if (iwad_dirs_built) { return; } // Look in the current directory. Doom always does this. AddIWADDir("."); // Add DOOMWADDIR if it is in the environment doomwaddir = getenv("DOOMWADDIR"); if (doomwaddir != NULL) { AddIWADDir(doomwaddir); } // Add dirs from DOOMWADPATH AddDoomWadPath(); #ifdef _WIN32 // Search the registry and find where IWADs have been installed. CheckUninstallStrings(); CheckCollectorsEdition(); CheckSteamEdition(); CheckDOSDefaults(); // Check for GUS patches installed with the BFG edition! CheckSteamGUSPatches(); #else // Standard places where IWAD files are installed under Unix. AddIWADDir("/usr/share/games/doom"); AddIWADDir("/usr/local/share/games/doom"); // [SVE] svillarreal #if !defined(__APPLE__) if((doomwaddir = GetApplicationPath())) AddIWADDir(doomwaddir); #endif #endif // Don't run this function again. iwad_dirs_built = true; }
std::wstring Environment::GetDataPath() { if (IsInstalled() || IsAppContainerProcess()) { return IO::Path::Combine( GetKnownFolderPath(FOLDERID_LocalAppData), TEXT("PicoTorrent")); } return GetApplicationPath(); }
void ApplicationList::SaveSettings(QSettings *programSettings) { QStringList names; QStringList paths; for (int i = 0; i < GetApplicationCount(); i++) { names << GetApplicationName(i); paths << GetApplicationPath(i); } programSettings->setValue(SETTINGS_APPLICATION_NAMES, names); programSettings->setValue(SETTINGS_APPLICATION_PATHS, paths); }
wxString GetApplicationDir() { wxString path; /* check APPDIR on unix's */ #ifndef __WXMSW__ # ifndef __WXMAC__ wxGetEnv(wxT("APPDIR"), &path); if (!path.IsEmpty()) return path; # endif #endif path = GetApplicationPath(); if (path.IsEmpty()) return wxGetCwd(); else { wxFileName fname(path); return fname.GetPath(wxPATH_GET_VOLUME); } }
void FileContextMenuExt::OnVerbScanFileName(HWND hWnd) { ShellExecute( NULL, L"open", GetApplicationPath().c_str(), L"-Scan", NULL, SW_SHOWNORMAL ); }
string GetApplicationDirectory() { string app_path = GetApplicationPath(); string app_dir = ExtractParentDirectory(app_path); return app_dir; }
TString GetApplicationName() { return GetFileName(GetApplicationPath(), false); }
TString GetApplicationDirectory() { return GetFileDirectory(GetApplicationPath()); }
void RunScript(FILE * script, const char * path) { ErrFunc_f old = InstallErrFunc(ScriptError, NULL); char * mem; int len, ok; char strbuf[1024]; strcpy(strbuf, path); strcat(strbuf, DIR_STR); MakeDirExist(strbuf); strcat(strbuf, "Installer Log.txt"); scriptLog = fopen(strbuf, "w"); if (scriptLog) fprintf(scriptLog, "Installing X-Plane to %s.\n", path); char from_buf[1024], to_buf[1024], partial[1024]; const char * app_path = GetApplicationPath(); if (app_path == NULL) { return; } bool condition = true; while (get_line(script, strbuf, sizeof(strbuf)-1)) { char * t; char * p = strbuf; t = next_token(&p); if (t == NULL) continue; if (!strcmp(t, "NOCONDITION")) { condition = true; } if (!strcmp(t, "ELSE")) { condition = !condition; } if (!strcmp(t, "MESSAGE")) { if (scriptLog) fprintf(scriptLog, "Note: %s\n", p); DoUserAlert(p); } if (!strcmp(t, "CONDITION")) { if (scriptLog) fprintf(scriptLog, "Checking: %s\n", p); condition = ConfirmMessage(p, "Yes", "No"); if (scriptLog) fprintf(scriptLog, "Answer: %s\n", condition ? "yes" : "no"); } if (!strcmp(t, "UPDATE")) { if (scriptLog) fprintf(scriptLog, "Running update.\n"); if (condition) RunInstaller(path); } if (!strcmp(t, "COPY")) { t = next_token(&p); float indi = -1.0; sprintf(msgBuf, "Installing %s...", t); ShowProgressMessage(msgBuf, &indi); strcpy(from_buf, app_path); strip_to_delim(from_buf,DIR_CHAR); strcat(from_buf, t); strcpy(to_buf, path); strcat(to_buf, DIR_STR); strcat(to_buf, p); normalize_dir_chars(to_buf); normalize_dir_chars(from_buf); if (condition) { if (scriptLog) fprintf(scriptLog, "Copying %s to %s\n", from_buf, to_buf); ok = FileToBlock(from_buf, &mem, &len); if (!ok) return; ok = BlockToFile(to_buf, mem); if (!ok) return; free(mem); } else { if (scriptLog) fprintf(scriptLog, "Not copying %s to %s\n", from_buf, to_buf); } } if (!strcmp(t, "UNZIP")) { t = next_token(&p); sprintf(msgBuf, "Installing %s...", t); strcpy(from_buf, app_path); strip_to_delim(from_buf,DIR_CHAR); strcat(from_buf, t); if (!strcmp(p, "/")) { strcpy(partial, path); strcat(partial, DIR_STR); } else { strcpy(partial, path); strcat(partial, DIR_STR); strcat(partial, p); } normalize_dir_chars(partial); normalize_dir_chars(from_buf); if (condition) { if (scriptLog) fprintf(scriptLog, "Unzipping %s to %s\n", from_buf, partial); unzFile unz = unzOpen(from_buf); if (unz == NULL) { ReportError("Unable to open zip file.", EUNKNOWN, from_buf); return; } unz_global_info global; unzGetGlobalInfo(unz, &global); unzGoToFirstFile(unz); int counter = 0; do { char zip_path[1024]; unz_file_info info; unzGetCurrentFileInfo(unz, &info, zip_path, sizeof(zip_path), NULL, 0, NULL, 0); sprintf(msgBuf, "Installing %s...", zip_path); float prog = (global.number_entry > 0) ? ((float) counter / (float) global.number_entry) : -1.0; ShowProgressMessage(msgBuf, &prog); ++counter; strcpy(to_buf, partial); strcat(to_buf, zip_path); normalize_dir_chars(to_buf); strip_to_delim(to_buf, DIR_CHAR); MakeDirExist(to_buf); if (info.uncompressed_size == 0) continue; char * mem = (char *) malloc(info.uncompressed_size); if (!mem) { ReportError("Out of memory", ENOMEM, NULL); return; } unzOpenCurrentFile(unz); int result = unzReadCurrentFile(unz,mem, info.uncompressed_size); if (result != info.uncompressed_size) { ReportError("Could not read installer archive.", EUNKNOWN, zip_path); } unzCloseCurrentFile(unz); strcpy(to_buf, partial); strcat(to_buf, zip_path); normalize_dir_chars(to_buf); FILE * fi = fopen(to_buf, "wb"); if (fi == NULL) { ReportError("Could not create file", errno, to_buf); return; } result = fwrite(mem, 1, info.uncompressed_size, fi); if (result != info.uncompressed_size) { ReportError("Could not read installer archive.", errno, to_buf); } fclose(fi); free(mem); } while(unzGoToNextFile(unz) == UNZ_OK); unzClose(unz); } else { if (scriptLog) fprintf(scriptLog, "Not unzipping %s to %s\n", from_buf, partial); } } } InstallErrFunc(old, NULL); if (scriptLog) fprintf(scriptLog, "Installer completed successfully.\n"); if (scriptLog) fclose(scriptLog); DoUserAlert("Installation was successful!"); }
ERMsg CUISolutionMesonetDaily::Execute(CCallback& callback) { ERMsg msg; int firstYear = as<int>(FIRST_YEAR); int lastYear = as<int>(LAST_YEAR); size_t nbYears = lastYear - firstYear + 1; callback.PushTask(m_name + " : " + GetString(IDS_UPDATE_FILE), nbYears); callback.AddMessage(GetString(IDS_UPDATE_FILE)); string workingDir = GetDir(WORKING_DIR); CTime today = CTime::GetCurrentTime(); callback.AddMessage(GetString(IDS_UPDATE_DIR)); callback.AddMessage(workingDir, 1); callback.AddMessage(GetString(IDS_UPDATE_FROM)); callback.AddMessage(SERVER_NAME, 1); callback.AddMessage(""); //open a connection on the server CInternetSessionPtr pSession; CFtpConnectionPtr pConnection; msg = GetFtpConnection(SERVER_NAME, pConnection, pSession, PRE_CONFIG_INTERNET_ACCESS, Get(USER_NAME), Get(PASSWORD)); if (msg) msg = UpdateStationList(pConnection, callback); if (msg) { CFileInfoVector dirList; UtilWWW::FindDirectories(pConnection, SUB_DIR, dirList); pConnection->Close(); pSession->Close(); for (size_t i = 0; i < dirList.size() && msg; i++) { string dirName = GetLastDirName(dirList[i].m_filePath); int year = ToInt(dirName); if (year >= firstYear && year <= lastYear) { msg = GetFtpConnection(SERVER_NAME, pConnection, pSession, PRE_CONFIG_INTERNET_ACCESS, Get(USER_NAME), Get(PASSWORD)); int nbDownload = 0; string yearPage = SUB_DIR + dirName; string outputPath = workingDir + dirName + "/"; //Load files list callback.AddMessage(ToString(year), 1); callback.AddMessage(GetString(IDS_LOAD_FILE_LIST), 2); CFileInfoVector fileList; msg += UtilWWW::FindFiles(pConnection, (yearPage + "/*.zip"), fileList, callback); callback.AddMessage(GetString(IDS_NB_FILES_FOUND) + ToString(fileList.size()) + ")", 2); pConnection->Close(); pSession->Close(); //clean list for (CFileInfoVector::iterator it = fileList.begin(); it != fileList.end() && msg;) { string fileTitle = GetFileTitle(it->m_filePath); string filePathZip = outputPath + fileTitle + ".zip"; string filePathWea = outputPath + fileTitle + ".wea"; if (UtilWWW::IsFileUpToDate(*it, filePathWea, false)) it = fileList.erase(it); else it++; msg += callback.StepIt(0); } callback.AddMessage(GetString(IDS_NB_FILES_CLEARED) + ToString(fileList.size()), 2); //download all files int nbRun = 0; int curI = 0; StringVector tmp(IDS_FTP_DIRECTION, "|;"); callback.PushTask(tmp[0] + " " + dirName + " (" + ToString(fileList.size()) + " stations)", fileList.size()); while (curI < fileList.size() && msg) { nbRun++; CreateMultipleDir(outputPath); //open a connection on the server msg = GetFtpConnection(SERVER_NAME, pConnection, pSession, PRE_CONFIG_INTERNET_ACCESS, Get(USER_NAME), Get(PASSWORD)); for (CFileInfoVector::iterator it = fileList.begin(); it != fileList.end() && msg; it++) { string fileTitle = GetFileTitle(it->m_filePath); string filePathZip = outputPath + fileTitle + ".zip"; string filePathWea = outputPath + fileTitle + ".wea"; string stationPage = yearPage + "/" + fileTitle + ".zip"; msg = UtilWWW::CopyFile(pConnection, stationPage.c_str(), filePathZip.c_str(), INTERNET_FLAG_TRANSFER_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_DONT_CACHE); if (msg) { ASSERT(FileExists(filePathZip)); string app = GetApplicationPath() + "External\\7z.exe"; string param = " e \"" + filePathZip + "\" -y -o\"" + outputPath + "\""; ReplaceString(param, "\\", "/"); string command = app + param; msg += WinExecWait(command.c_str()); msg += RemoveFile(filePathZip); //update time stamp to the zip file boost::filesystem::path p(filePathWea); if (boost::filesystem::exists(p)) boost::filesystem::last_write_time(p, fileList[i].m_time);//std::time(0) nbDownload++; curI++; msg += callback.StepIt(); } } //if an error occur: try again if (!msg && !callback.GetUserCancel()) { if (nbRun < 5) { callback.AddMessage(msg); msg.asgType(ERMsg::OK); callback.PushTask("Waiting 2 seconds for server...", 100); for (size_t i = 0; i < 40 && msg; i++) { Sleep(50);//wait 50 milisec msg += callback.StepIt(); } callback.PopTask(); } } callback.AddMessage(GetString(IDS_NB_FILES_DOWNLOADED) + ToString(nbDownload), 2); pConnection->Close(); pSession->Close(); }//while callback.PopTask(); callback.StepIt(); }//year is included }//for all years }//if msg callback.PopTask(); return msg; }
EWXWEXPORT(wxString*,wxGetApplicationPath)() { wxString *result = new wxString(); *result = GetApplicationPath(); return result; }
bool CChainWalkContext::LoadCharset( std::string sName ) { m_vCharset.clear(); if (sName == "byte") { stCharset tCharset; int i; for (i = 0x00; i <= 0xff; i++) tCharset.m_PlainCharset[i] = (unsigned char) i; tCharset.m_nPlainCharsetLen = MAX_PLAIN_LEN; tCharset.m_sPlainCharsetName = sName; tCharset.m_sPlainCharsetContent = "0x00, 0x01, ... 0xff"; m_vCharset.push_back(tCharset); return true; } if(sName.substr(0, 6) == "hybrid") // Hybrid charset consisting of 2 charsets { if (sName.substr(6, 2) == "3(") { size_t pos = sName.find_last_of(')'); if (pos == std::string::npos) return false; m_ks = KeySpace::load(sName.substr(8, pos - 8).c_str(), CE_ASCII_BIN8 | CE_NULL_PADDED); // hybrid3(file name)#0-0 if (m_ks == NULL) return false; m_nHybridCharset = 3; return true; } else if (sName.substr(6, 2) == "2(") m_nHybridCharset = 2; else if (sName.substr(6, 1) == "(") m_nHybridCharset = 1; else { printf("hybrid version not supported\n"); return false; } } else m_nHybridCharset = 0; bool readCharset = false; std::vector<std::string> vLine; std::vector<std::string> internal_charset; vLine.clear(); internal_charset.clear(); internal_charset.push_back("byte = []"); internal_charset.push_back("alpha = [ABCDEFGHIJKLMNOPQRSTUVWXYZ]"); internal_charset.push_back("alpha-space = [ABCDEFGHIJKLMNOPQRSTUVWXYZ ]"); internal_charset.push_back("alpha-numeric = [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"); internal_charset.push_back("alpha-numeric-space = [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ]"); internal_charset.push_back("alpha-numeric-symbol14 = [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D]"); internal_charset.push_back("alpha-numeric-symbol14-space= [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x20]"); internal_charset.push_back("all = [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F]"); internal_charset.push_back("all-space = [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F\x20]"); internal_charset.push_back("alpha-numeric-symbol32-space = [ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F\x20]"); internal_charset.push_back("lm-frt-cp437 = [\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x7B\x7C\x7D\x7E\x80\x8E\x8F\x90\x92\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA5\xE0\xE1\xE2\xE3\xE4\xE6\xE7\xE8\xE9\xEA\xEB\xEE]"); internal_charset.push_back("lm-frt-cp850 = [\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x7B\x7C\x7D\x7E\x80\x8E\x8F\x90\x92\x99\x9A\x9C\x9D\x9F\xA5\xB5\xB6\xB7\xBD\xBE\xC7\xCF\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xDE\xE0\xE1\xE2\xE3\xE5\xE6\xE8\xE9\xEA\xEB\xED\xEF]"); internal_charset.push_back("lm-frt-cp437-850 = [\x20\x21\x22\x23\x24\x25\x26\x27\x28\x29\x2A\x2B\x2C\x2D\x2E\x2F\x30\x31\x32\x33\x34\x35\x36\x37\x38\x39\x3A\x3B\x3C\x3D\x3E\x3F\x40\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52\x53\x54\x55\x56\x57\x58\x59\x5A\x5B\x5C\x5D\x5E\x5F\x60\x7B\x7C\x7D\x7E\x80\x8E\x8F\x90\x92\x99\x9A\x9B\x9C\x9D\x9E\x9F\xA5\xB5\xB6\xB7\xBD\xBE\xC7\xCF\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xDE\xE0\xE1\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\xEA\xEB\xED\xEE\xEF]"); internal_charset.push_back("numeric = [0123456789]"); internal_charset.push_back("numeric-space = [0123456789 ]"); internal_charset.push_back("loweralpha = [abcdefghijklmnopqrstuvwxyz]"); internal_charset.push_back("loweralpha-space = [abcdefghijklmnopqrstuvwxyz ]"); internal_charset.push_back("loweralpha-numeric = [abcdefghijklmnopqrstuvwxyz0123456789]"); internal_charset.push_back("loweralpha-numeric-space = [abcdefghijklmnopqrstuvwxyz0123456789 ]"); internal_charset.push_back("loweralpha-numeric-symbol14 = [abcdefghijklmnopqrstuvwxyz0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D]"); internal_charset.push_back("loweralpha-numeric-all = [abcdefghijklmnopqrstuvwxyz0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F]"); internal_charset.push_back("loweralpha-numeric-symbol32-space= [abcdefghijklmnopqrstuvwxyz0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F\x20]"); internal_charset.push_back("mixalpha = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]"); internal_charset.push_back("mixalpha-space = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ ]"); internal_charset.push_back("mixalpha-numeric = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789]"); internal_charset.push_back("mixalpha-numeric-space = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ]"); internal_charset.push_back("mixalpha-numeric-symbol14 = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D]"); internal_charset.push_back("mixalpha-numeric-all = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F]"); internal_charset.push_back("mixalpha-numeric-symbol32-space = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F\x20]"); internal_charset.push_back("mixalpha-numeric-all-space = [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\x21\x40\x23\x24\x25\x5E\x26\x2A\x28\x29\x2D\x5F\x2B\x3D\x7E\x60\x5B\x5D\x7B\x7D\x7C\x5C\x3A\x3B\x22\x27\x3C\x3E\x2C\x2E\x3F\x2F\x20]"); #ifdef USE_INTEGRATED_CHARSET vLine = internal_charset; readCharset = true; #else #ifdef BOINC if ( boinc_ReadLinesFromFile( "charset.txt", vLine ) ) readCharset = true; else { vLine = internal_charset; readCharset = true; } #else if ( ReadLinesFromFile("charset.txt", vLine) ) readCharset = true; else if ( ReadLinesFromFile(GetApplicationPath() + "charset.txt", vLine) ) readCharset = true; else { vLine = internal_charset; readCharset = true; } #endif #endif if ( readCharset ) { int i; for (i = 0; (uint32_t)i < vLine.size(); i++) { // Filter comment if (vLine[i][0] == '#') continue; std::vector<std::string> vPart; if (SeperateString(vLine[i], "=", vPart)) { // sCharsetName std::string sCharsetName = TrimString(vPart[0]); if (sCharsetName == "") continue; // sCharsetName charset check bool fCharsetNameCheckPass = true; uint32_t j; for (j = 0; j < sCharsetName.size(); j++) { if ( !isalpha(sCharsetName[j]) && !isdigit(sCharsetName[j]) && (sCharsetName[j] != '-')) { fCharsetNameCheckPass = false; break; } } if (!fCharsetNameCheckPass) { printf("invalid charset name %s in charset configuration file\n", sCharsetName.c_str()); continue; } // sCharsetContent std::string sCharsetContent = TrimString(vPart[1]); if (sCharsetContent == "" || sCharsetContent == "[]") continue; if (sCharsetContent[0] != '[' || sCharsetContent[sCharsetContent.size() - 1] != ']') { printf("invalid charset content %s in charset configuration file\n", sCharsetContent.c_str()); continue; } sCharsetContent = sCharsetContent.substr(1, sCharsetContent.size() - 2); if (sCharsetContent.size() > MAX_PLAIN_LEN) { printf("charset content %s too long\n", sCharsetContent.c_str()); continue; } //printf("%s = [%s]\n", sCharsetName.c_str(), sCharsetContent.c_str()); // Is it a hybrid? if( m_nHybridCharset != 0 ) { std::vector<tCharset> vCharsets; if ( !GetHybridCharsets(sName, vCharsets) ) { std::cout << "Failed to GetHybridCharsets: " << sName << std::endl; return false; } if(sCharsetName == vCharsets[m_vCharset.size()].sName) { stCharset tCharset; tCharset.m_nPlainCharsetLen = sCharsetContent.size(); memcpy(tCharset.m_PlainCharset, sCharsetContent.c_str(), tCharset.m_nPlainCharsetLen); tCharset.m_sPlainCharsetName = sCharsetName; tCharset.m_sPlainCharsetContent = sCharsetContent; tCharset.m_nPlainLenMin = vCharsets[m_vCharset.size()].nPlainLenMin; tCharset.m_nPlainLenMax = vCharsets[m_vCharset.size()].nPlainLenMax; m_vCharset.push_back(tCharset); if(vCharsets.size() == m_vCharset.size()) return true; //i = 0; // Start the lookup over again for the next charset // Sc00bz indicates this fixes a bug of skipping line 1 // of charset.txt i = -1; // Start the lookup over again for the next charset } } else if (sCharsetName == sName) { stCharset tCharset; tCharset.m_nPlainCharsetLen = sCharsetContent.size(); memcpy(tCharset.m_PlainCharset, sCharsetContent.c_str(), tCharset.m_nPlainCharsetLen); tCharset.m_sPlainCharsetName = sCharsetName; tCharset.m_sPlainCharsetContent = sCharsetContent; m_vCharset.push_back(tCharset); return true; } } } printf("charset %s not found in charset.txt\n", sName.c_str()); } else printf("can't open charset configuration file\n"); return false; }
CString CAddonUpdaterApp::GetProfileFile() { return GetApplicationPath() + _T("\\AddonUpdater.ini"); }