void AppendStringToFile(const string filename, const string text) { FILE *fp = NULL; if (GetPlatformID() == PLATFORM_ID_LINUX) { fp = fopen(filename.c_str(), "a+"); } else { fp = fopen(filename.c_str(), "ab"); if (!fp) { fp = fopen(filename.c_str(), "wb"); } } if (!fp) { //Uhh.... bad idea, could create infinite loop //LogError("Unable to create/append to %s", text); return; } fwrite(text.c_str(), text.size(), 1, fp); fclose(fp); }
void BaseApp::OnEnterBackground() { if (!m_bIsInBackground) { m_bIsInBackground = true; #ifdef _DEBUG LogMsg("Entering background"); #endif #ifndef PLATFORM_ANDROID if (GetEmulatedPlatformID() == PLATFORM_ID_ANDROID) m_sig_unloadSurfaces(); #endif if (GetPlatformID() != PLATFORM_ID_ANDROID) { //android will do it elsewhere, but for other platforms we fake this message here m_sig_pre_enterbackground(NULL); } m_sig_enterbackground(NULL); } GetAudioManager()->Suspend(); //ResetTouches(); //Turns out we don't need this }
void ClSetup::SetupCl(int platform_index, int device_index) { platform = GetPlatformID(platform_index); PrintPlatformInfo(platform); device = GetDeviceID(device_index); PrintDeviceInfo(device); context = CreateContext(); queue = CreateCommandQueue(); bInit = true; }
void TextScanner::AppendToFile( string fileName, bool bAddBasePath /*= true*/ ) { if (m_lines.empty()) return; if (bAddBasePath) { fileName = GetBaseAppPath()+fileName; } FILE *fp = NULL; if (GetPlatformID() == PLATFORM_ID_LINUX) { fp = fopen(fileName.c_str(), "a+"); } else { fp = fopen(fileName.c_str(), "ab"); if (!fp) { fp = fopen(fileName.c_str(), "wb"); } } if (!fp) { //Uhh.... bad idea, could create infinite loop //LogError("Unable to create/append to %s", text); return; } string temp; for (uint32 i=0; i < m_lines.size(); i++) { temp = m_lines[i]+"\r\n"; fwrite(temp.c_str(), temp.size(), 1, fp); } fclose(fp); // }
void GameList::CompressISO() { const auto original_path = GetSelectedGame(); auto file = GameFile(original_path); const bool compressed = (file.GetBlobType() == DiscIO::BlobType::GCZ); if (!compressed && file.GetPlatformID() == DiscIO::Platform::WII_DISC) { QMessageBox wii_warning(this); wii_warning.setIcon(QMessageBox::Warning); wii_warning.setText(tr("Are you sure?")); wii_warning.setInformativeText( tr("Compressing a Wii disc image will irreversibly change the compressed copy by removing " "padding data. Your disc image will still work.")); wii_warning.setStandardButtons(QMessageBox::Yes | QMessageBox::No); if (wii_warning.exec() == QMessageBox::No) return; } QString dst_path = QFileDialog::getSaveFileName( this, compressed ? tr("Select where you want to save the decompressed image") : tr("Select where you want to save the compressed image"), QFileInfo(GetSelectedGame()) .dir() .absoluteFilePath(file.GetGameID()) .append(compressed ? QStringLiteral(".gcm") : QStringLiteral(".gcz")), compressed ? tr("Uncompressed GC/Wii images (*.iso *.gcm") : tr("Compressed GC/Wii images (*.gcz)")); if (dst_path.isEmpty()) return; QProgressDialog progress_dialog(compressed ? tr("Decompressing...") : tr("Compressing..."), tr("Abort"), 0, 100, this); progress_dialog.setWindowModality(Qt::WindowModal); bool good; if (compressed) { good = DiscIO::DecompressBlobToFile(original_path.toStdString(), dst_path.toStdString(), &CompressCB, &progress_dialog); } else { good = DiscIO::CompressFileToBlob(original_path.toStdString(), dst_path.toStdString(), file.GetPlatformID() == DiscIO::Platform::WII_DISC ? 1 : 0, 16384, &CompressCB, &progress_dialog); } if (good) { QMessageBox(QMessageBox::Information, tr("Success!"), tr("Successfully compressed image."), QMessageBox::Ok, this) .exec(); } else { QErrorMessage(this).showMessage(tr("Dolphin failed to complete the requested action.")); } }