void DatabaseJobContext::OnResult() { //done: 이 함수는 반드시 IO스레드풀에서 수행되어야 한다. 그렇지 않으면 CRASH시키기 CRASH_ASSERT(LThreadType == THREAD_IO_WORKER); CRASH_ASSERT(LWorkerThreadId >= MAX_DB_THREAD); if (mSuccess) OnSuccess(); else OnFail(); }
void UrlStringBoxLoader::LoadComplete() { if(HttpClient->WasError()) { OnFail(); return; } QString res = HttpClient->GetContent(); if(Argument.isEmpty()) { Argument = "[\r\n]"; Capture = ResourceModelUrl::Split; } QStringList r; if(Capture == ResourceModelUrl::Split) { r = res.split(QRegExp(Argument),QString::SkipEmptyParts); }else { QRegExp regexp(Argument); int state_position = 0; while ((state_position = regexp.indexIn(res, state_position)) != -1) { if(regexp.captureCount()>0) r.append(regexp.cap(1)); else if(regexp.captureCount()==0) r.append(regexp.cap(0)); state_position += regexp.matchedLength(); } } UrlIterator++; FailCount = 0; if(UrlIterator >= UrlList.length()) { emit DataLoadedCompletely(); UrlIterator = 0; } emit Loaded(r); }
void UrlStringBoxLoader::Reqeust() { Waiter->WaitForSignal(HttpClient,SIGNAL(Finished()),this,SLOT(LoadComplete()),this, SLOT(OnFail())); HttpClient->Get(UrlList.at(UrlIterator)); }
wxThread::ExitCode ModderTask::TaskStart() { // Get the mod list ModList *modList = m_inst->GetModList(); wxFileName mcBin = m_inst->GetBinDir(); wxFileName mcJar = m_inst->GetMCJar(); wxFileName mcBackup = m_inst->GetMCBackup(); // Nothing to do if there are no jar mods to install, no backup and just the mc jar if(mcJar.FileExists() && !mcBackup.FileExists() && modList->empty()) { m_inst->SetNeedsRebuild(false); return (ExitCode)1; } SetStatus(_("Installing mods - backing up minecraft.jar...")); if (!mcBackup.FileExists() && !wxCopyFile(mcJar.GetFullPath(), mcBackup.GetFullPath())) { OnFail(_("Failed to back up minecraft.jar")); return (ExitCode)0; } if (mcJar.FileExists() && !wxRemoveFile(mcJar.GetFullPath())) { OnFail(_("Failed to delete old minecraft.jar")); return (ExitCode)0; } // TODO: good spot for user cancel check? or not... TaskStep(); // STEP 1 SetStatus(_("Installing mods - Opening minecraft.jar")); wxFFileOutputStream jarStream(mcJar.GetFullPath()); wxZipOutputStream zipOut(jarStream); // Files already added to the jar. // These files will be skipped. std::set<wxString> addedFiles; // Modify the jar TaskStep(); // STEP 2 SetStatus(_("Installing mods - Adding mod files...")); for (ModList::const_reverse_iterator iter = modList->rbegin(); iter != modList->rend(); iter++) { wxFileName modFileName = iter->GetFileName(); SetStatus(_("Installing mods - Adding ") + modFileName.GetFullName()); if (iter->IsZipMod()) { wxFFileInputStream modStream(modFileName.GetFullPath()); wxZipInputStream zipStream(modStream); std::auto_ptr<wxZipEntry> entry; while (entry.reset(zipStream.GetNextEntry()), entry.get() != NULL) { if (entry->IsDir()) continue; wxString name = entry->GetName(); if (addedFiles.count(name) == 0) { if (!zipOut.CopyEntry(entry.release(), zipStream)) break; addedFiles.insert(name); } } } else { wxFileName destFileName = modFileName; destFileName.MakeRelativeTo(m_inst->GetInstModsDir().GetFullPath()); wxString destFile = destFileName.GetFullPath(); if (addedFiles.count(destFile) == 0) { wxFFileInputStream input(modFileName.GetFullPath()); zipOut.PutNextEntry(destFile); zipOut.Write(input); addedFiles.insert(destFile); } } } { wxFFileInputStream inStream(mcBackup.GetFullPath()); wxZipInputStream zipIn(inStream); std::auto_ptr<wxZipEntry> entry; while (entry.reset(zipIn.GetNextEntry()), entry.get() != NULL) { wxString name = entry->GetName(); if (!name.Matches("META-INF*") && addedFiles.count(name) == 0) { if (!zipOut.CopyEntry(entry.release(), zipIn)) break; addedFiles.insert(name); } } } // Recompress the jar TaskStep(); // STEP 3 SetStatus(_("Installing mods - Recompressing jar...")); m_inst->SetNeedsRebuild(false); m_inst->UpdateVersion(true); return (ExitCode)1; }
Token* LexicalAnalyzer::GetNextToken() { if(IsEndOfFile()) return EndOfFileToken(); char c = NextChar(); m_lexemeBegin = m_forward; m_dfa->Reset(); int m_currentTokenTypeId = TOKEN_Unrecognized; while(true) { m_currentTokenTypeId = m_dfa->Move(c); if(m_currentTokenTypeId == TOKEN_Unrecognized) { c = NextChar(); } else { break; } } Retract(); if(IsIgnoredToken(m_currentTokenTypeId)) { return GetNextToken(); } else { Token* token; string lexeme; TokenValue* tokenValue; vector<PlainCharacter*>& buffer = m_buffer->InnerBuffer(); m_buffer->ExtractString(m_lexemeBegin, m_forward - m_lexemeBegin + 1, lexeme); tokenValue = new TokenValue("", buffer[m_lexemeBegin]->Row, buffer[m_lexemeBegin]->Column); token = new Token(m_currentTokenTypeId, tokenValue); if(IsCompositeToken(m_currentTokenTypeId)) { if(m_reservedWordsToTokenTypeIdMap.find(lexeme) != m_reservedWordsToTokenTypeIdMap.end()) { token->TypeId = g_TokenTypesMap[m_reservedWordsToTokenTypeIdMap[lexeme]]->Id; m_recognizedTokens.push_back(token); return token; } } if(IsSpecialToken(m_currentTokenTypeId)) { m_recognizedTokens.push_back(token); return token; } else if(IsIdentifierToken(m_currentTokenTypeId)) { // save the index of the identifier in the symbol table token->Value->Data = m_symbolTable.size(); m_symbolTable.push_back(token); } token->Value->Lexeme = lexeme; if(IsErrorToken(m_currentTokenTypeId)) { OnFail(token); } m_recognizedTokens.push_back(token); return token; } }
void ModderTask::TaskStart() { // Get the mod list const ModList *modList = m_inst->GetModList(); wxFileName mcBin = m_inst->GetBinDir(); wxFileName mcJar = m_inst->GetMCJar(); wxFileName mcBackup = m_inst->GetMCBackup(); SetStatus(_("Installing mods - backing up minecraft.jar...")); if (!mcBackup.FileExists() && !wxCopyFile(mcJar.GetFullPath(), mcBackup.GetFullPath())) { OnFail(_("Failed to back up minecraft.jar")); return; } if (mcJar.FileExists() && !wxRemoveFile(mcJar.GetFullPath())) { OnFail(_("Failed to delete old minecraft.jar")); return; } if (TestDestroy()) return; TaskStep(); // STEP 1 SetStatus(_("Installing mods - Opening minecraft.jar")); wxFFileOutputStream jarStream(mcJar.GetFullPath()); wxZipOutputStream zipOut(jarStream); { wxFFileInputStream inStream(mcBackup.GetFullPath()); wxZipInputStream zipIn(inStream); std::auto_ptr<wxZipEntry> entry; while (entry.reset(zipIn.GetNextEntry()), entry.get() != NULL) if (!entry->GetName().Matches(_("META-INF*"))) if (!zipOut.CopyEntry(entry.release(), zipIn)) break; } // Modify the jar TaskStep(); // STEP 2 SetStatus(_("Installing mods - Adding mod files...")); for (ConstModIterator iter = modList->begin(); iter != modList->end(); iter++) { wxFileName modFileName = iter->GetFileName(); SetStatus(_("Installing mods - Adding ") + modFileName.GetFullName()); if (iter->IsZipMod()) { wxFFileInputStream modStream(modFileName.GetFullPath()); TransferZipArchive(modStream, zipOut); } else { wxFileName destFileName = modFileName; destFileName.MakeRelativeTo(m_inst->GetInstModsDir().GetFullPath()); wxFFileInputStream input(modFileName.GetFullPath()); zipOut.PutNextEntry(destFileName.GetFullPath()); zipOut.Write(input); } } // Recompress the jar TaskStep(); // STEP 3 SetStatus(_("Installing mods - Recompressing jar...")); m_inst->SetNeedsRebuild(false); }