void ShaderEditor::onGUIMenu() { if(ImGui::BeginMenuBar()) { if(ImGui::BeginMenu("File")) { if (ImGui::MenuItem("New")) newGraph(); if (ImGui::MenuItem("Open")) load(); if (ImGui::MenuItem("Save", nullptr, false, m_path.isValid())) save(m_path.c_str()); if (ImGui::MenuItem("Save as")) { getSavePath(); if (m_path.isValid()) save(m_path.c_str()); } ImGui::EndMenu(); } if (ImGui::BeginMenu("Edit")) { if (ImGui::MenuItem("Undo", nullptr, false, canUndo())) undo(); if (ImGui::MenuItem("Redo", nullptr, false, canRedo())) redo(); ImGui::EndMenu(); } if (ImGui::MenuItem("Generate", nullptr, false, m_path.isValid())) { generate(m_path.c_str(), ShaderType::VERTEX); generate(m_path.c_str(), ShaderType::FRAGMENT); generateMain(m_path.c_str()); } ImGui::EndMenuBar(); } }
boost::shared_ptr<Lyric> LyricSourceLRC::Get(const metadb_handle_ptr &track) { std::wstring path = getSavePath(track); std::string lyric; HANDLE hf = CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, NULL, NULL); if(hf == INVALID_HANDLE_VALUE) return boost::shared_ptr<Lyric>(new LRCLyric(lyric, path)); DWORD size = SetFilePointer(hf, 0, 0, FILE_END); SetFilePointer(hf, 0, 0, FILE_BEGIN); char *data = new char[size]; DWORD dwRead; ReadFile(hf, (void *)data, size, &dwRead, NULL); CloseHandle(hf); if(data[0] == 0xEF && data[1] == 0xBB && data[2] == 0xBF) //utf8 bom { lyric.assign(data + 3); delete [] data; } else if(data[0] == 0xFF && data[1] == 0xFE) //utf16 bom { lyric = EncodingFunc::ToUTF8((wchar_t *)data); delete [] data; } else { lyric.assign(data); delete [] data; } return boost::shared_ptr<Lyric>(new LRCLyric(lyric, path)); }
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) { Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); if (getError().getCode() != Common::kNoError) return false; // recreate FSNode since checkPath may have changed/created the directory Common::FSNode savePath(savePathName); Common::FSNode file = savePath.getChild(filename); // FIXME: remove does not exist on all systems. If your port fails to // compile because of this, please let us know (scummvm-devel or Fingolfin). // There is a nicely portable workaround, too: Make this method overloadable. if (remove(file.getPath().c_str()) != 0) { #ifndef _WIN32_WCE if (errno == EACCES) setError(Common::kWritePermissionDenied, "Search or write permission denied: "+file.getName()); if (errno == ENOENT) setError(Common::kPathDoesNotExist, "removeSavefile: '"+file.getName()+"' does not exist or path is invalid"); #endif return false; } else { return true; } }
void currentAnalyzer::saveData( const QString& prefix, QString delimiter ) { QString path = getSavePath(); if( path.isEmpty() ) { return; } QString filename = path + "/" + prefix + _startDateTime.toString( "yyyy-MM-dd__hh-mm-ss" ) + ".csv"; QFile file( filename ); if( file.open( QIODevice::ReadWrite ) ) { QTextStream stream( &file ); for( unsigned int i = 0; i < _dataVector.size(); i++ ) { stream << _dataVector[i].time.toString( "hh:mm:ss,zzz" ) << delimiter << QString::number( _dataVector[i].compPosition ) << delimiter << QString::number( _dataVector[i].compDepth ) << delimiter << QString::number( _dataVector[i].ventVolume ) << "\r\n"; // \r so that it is readable on windows as well } emit infoText( "Daten gespeichert (" + filename + ")." ); } else { emit infoText( "Fehler: Daten konnten nicht in " + path + " gespeichert werden!" ); } }
void ExportWizard::slotChoosePath() { QString savePath = getSavePath(m_ui->filePath->text(), "png", tr("Choose the Image file"), tr("Images (*.jpeg *.jpg *.png *.bmp *.tif *.tiff)")); if (!savePath.isEmpty()) m_ui->filePath->setText(savePath); }
void ExportWizard::slotChooseSvgPath() { QString savePath = getSavePath(m_ui->svgFilePath->text(), "svg", tr("Choose the SVG file"), tr("SVG (*.svg)")); if (!savePath.isEmpty()) m_ui->svgFilePath->setText(savePath); }
void ExportWizard::slotChoosePdfPath() { QString savePath = getSavePath(m_pdfPrinter->outputFileName(), "pdf", tr("Choose the PDF file"), tr("PDF (*.pdf)")); if (!savePath.isEmpty()) m_pdfPrinter->setOutputFileName(savePath); }
Common::StringArray GBAMPSaveFileManager::listSavefiles(const Common::String &pattern) { enum { TYPE_NO_MORE = 0, TYPE_FILE = 1, TYPE_DIR = 2 }; char name[256]; { char dir[128]; strcpy(dir, getSavePath().c_str()); char *realName = dir; if ((strlen(dir) >= 4) && (dir[0] == 'm') && (dir[1] == 'p') && (dir[2] == ':') && (dir[3] == '/')) { realName += 4; } // consolePrintf("Real cwd:%d\n", realName); char *p = realName; while (*p) { if (*p == '\\') *p = '/'; p++; } // consolePrintf("Real cwd:%d\n", realName); FAT_chdir(realName); } // consolePrintf("Save path: '%s', pattern: '%s'\n", getSavePath(), pattern); int fileType = FAT_FindFirstFileLFN(name); Common::StringArray list; do { if (fileType == TYPE_FILE) { FAT_GetLongFilename(name); for (int r = 0; name[r] != 0; r++) { name[r] = tolower(name[r]); } if (Common::matchString(name, pattern.c_str())) { list.push_back(name); } } } while ((fileType = FAT_FindNextFileLFN(name))); FAT_chdir("/"); return list; }
Common::InSaveFile *GBAMPSaveFileManager::openForLoading(const Common::String &filename) { Common::String fileSpec = getSavePath(); if (fileSpec.lastChar() != '/') fileSpec += '/'; fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); return DS::DSFileStream::makeFromPath(fileSpec, false); }
void MainLoop::saveUI(PModel& model, Model::GameType type, View::SplashType splashType) { ProgressMeter meter(1.0 / 62500); Square::progressMeter = &meter; view->displaySplash(meter, splashType); string path = getSavePath(model.get(), type); MEASURE(saveGame(model, path), "saving time"); view->clearSplash(); Square::progressMeter = nullptr; if (type == Model::GameType::RETIRED_KEEPER && options->getBoolValue(OptionId::ONLINE)) uploadFile(path); }
Common::OutSaveFile *GBAMPSaveFileManager::openForSaving(const Common::String &filename, bool compress) { Common::String fileSpec = getSavePath(); if (fileSpec.lastChar() != '/') fileSpec += '/'; fileSpec += filename; // consolePrintf("Opening the file: %s\n", fileSpec.c_str()); Common::WriteStream *stream = DS::DSFileStream::makeFromPath(fileSpec, true); // Use a write buffer stream = Common::wrapBufferedWriteStream(stream, SAVE_BUFFER_SIZE); return new OutSaveFile(stream); }
Common::InSaveFile *DefaultSaveFileManager::openRawFile(const Common::String &filename) { // Assure the savefile name cache is up-to-date. assureCached(getSavePath()); if (getError().getCode() != Common::kNoError) return nullptr; SaveFileCache::const_iterator file = _saveFileCache.find(filename); if (file == _saveFileCache.end()) { return nullptr; } else { // Open the file for loading. Common::SeekableReadStream *sf = file->_value.createReadStream(); return sf; } }
Common::InSaveFile *DefaultSaveFileManager::openForLoading(const char *filename) { char buf[256]; join_paths(filename, getSavePath(), buf, sizeof(buf)); #ifdef USE_ZLIB GzipSaveFile *sf = new GzipSaveFile(buf, false); #else StdioSaveFile *sf = new StdioSaveFile(buf, false); #endif if (!sf->isOpen()) { delete sf; sf = 0; } return sf; }
Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename, bool compress) { // Ensure that the savepath is valid. If not, generate an appropriate error. Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); if (getError().getCode() != Common::kNoError) return 0; // recreate FSNode since checkPath may have changed/created the directory Common::FSNode savePath(savePathName); Common::FSNode file = savePath.getChild(filename); // Open the file for saving Common::WriteStream *sf = file.createWriteStream(); return compress ? Common::wrapCompressedWriteStream(sf) : sf; }
DWORD LyricSourceLRC::Save(const metadb_handle_ptr &track, Lyric &lyric) { std::wstring path = getSavePath(track); HANDLE hf = CreateFile(path.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, NULL, NULL); if(hf == INVALID_HANDLE_VALUE) return 0; DWORD unused; //{"UTF-8", "UTF-8(BOM)", "UTF-16", "CP949"}; if(m_config["lrcsaveencoding"] == "1") { const unsigned char bomtemp[] = {0xEF, 0xBB, 0xBF}; WriteFile(hf, bomtemp, 3, &unused, NULL); } else if(m_config["lrcsaveencoding"] == "2") { const unsigned char bomtemp[] = {0xFF, 0xFE}; WriteFile(hf, bomtemp, 2, &unused, NULL); } for(std::vector<LyricLine>::const_iterator it = lyric.GetIteratorAt(0); !lyric.IsEndOfLyric(it); it ++) { std::stringstream str; str << "[" << std::setfill('0') << std::setw(2) << it->time / 60 / 100 << ":" << std::setw(2) << it->time / 100 % 60 << "." << std::setw(2) << it->time % 100 << "]" << it->lyric << "\r\n"; if(m_config["lrcsaveencoding"] == "0" || m_config["lrcsaveencoding"] == "1") WriteFile(hf, str.str().c_str(), str.str().size(), &unused, NULL); else if(m_config["lrcsaveencoding"] == "2") { std::wstring wstr = EncodingFunc::ToUTF16(str.str()); WriteFile(hf, wstr.c_str(), wstr.size(), &unused, NULL); } else if(m_config["lrcsaveencoding"] == "3") { std::wstring wstr = EncodingFunc::ToUTF16(str.str()); CHAR mbstr[512]; int len = WideCharToMultiByte(949, NULL, wstr.c_str(), -1, mbstr, 512, NULL, NULL); mbstr[len] = 0; WriteFile(hf, mbstr, len, &unused, NULL); } } CloseHandle(hf); return 1; }
/** * Initiate the upload process when the screenshot has been taken. * @brief Systray::screenshotDone * @param returnCode * @param fileName * @param output */ void Systray::screenshotDone(int returnCode, QString fileName, QString output) { if (returnCode != 0) { trayIcon->showMessage(tr("Error!"), output, QSystemTrayIcon::Warning); return; } Upload *u = new Upload(fileName); connect(u, SIGNAL(started()), this, SLOT(puushStarted())); connect(u, SIGNAL(finished(QString)), this, SLOT(puushDone(QString))); if (s.value(Settings::LOCAL_SAVE_ENABLED).toBool()) { QDir root = QDir::root(); root.mkpath(getSaveDirectory()); QFile::copy(fileName, getSavePath()); } }
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) { // Assure the savefile name cache is up-to-date. assureCached(getSavePath()); if (getError().getCode() != Common::kNoError) return false; #ifdef USE_LIBCURL // Update file's timestamp Common::HashMap<Common::String, uint32> timestamps = loadTimestamps(); Common::HashMap<Common::String, uint32>::iterator it = timestamps.find(filename); if (it != timestamps.end()) { timestamps.erase(it); saveTimestamps(timestamps); } #endif // Obtain node if exists. SaveFileCache::const_iterator file = _saveFileCache.find(filename); if (file == _saveFileCache.end()) { return false; } else { const Common::FSNode fileNode = file->_value; // Remove from cache, this invalidates the 'file' iterator. _saveFileCache.erase(file); file = _saveFileCache.end(); // FIXME: remove does not exist on all systems. If your port fails to // compile because of this, please let us know (scummvm-devel). // There is a nicely portable workaround, too: Make this method overloadable. if (remove(fileNode.getPath().c_str()) != 0) { #ifndef _WIN32_WCE if (errno == EACCES) setError(Common::kWritePermissionDenied, "Search or write permission denied: "+fileNode.getName()); if (errno == ENOENT) setError(Common::kPathDoesNotExist, "removeSavefile: '"+fileNode.getName()+"' does not exist or path is invalid"); #endif return false; } else { return true; } } }
Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String &filename) { // Ensure that the savepath is valid. If not, generate an appropriate error. Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); if (getError().getCode() != Common::kNoError) return 0; // recreate FSNode since checkPath may have changed/created the directory Common::FSNode savePath(savePathName); Common::FSNode file = savePath.getChild(filename); if (!file.exists()) return 0; // Open the file for reading Common::SeekableReadStream *sf = file.createReadStream(); return Common::wrapCompressedReadStream(sf); }
Common::StringArray DefaultSaveFileManager::listSavefiles(const Common::String &pattern) { // Assure the savefile name cache is up-to-date. assureCached(getSavePath()); if (getError().getCode() != Common::kNoError) return Common::StringArray(); Common::HashMap<Common::String, bool> locked; for (Common::StringArray::const_iterator i = _lockedFiles.begin(), end = _lockedFiles.end(); i != end; ++i) { locked[*i] = true; } Common::StringArray results; for (SaveFileCache::const_iterator file = _saveFileCache.begin(), end = _saveFileCache.end(); file != end; ++file) { if (!locked.contains(file->_key) && file->_key.matchString(pattern, true)) { results.push_back(file->_key); } } return results; }
Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename, bool compress) { // Assure the savefile name cache is up-to-date. const Common::String savePathName = getSavePath(); assureCached(savePathName); if (getError().getCode() != Common::kNoError) return nullptr; for (Common::StringArray::const_iterator i = _lockedFiles.begin(), end = _lockedFiles.end(); i != end; ++i) { if (filename == *i) { return nullptr; //file is locked, no saving available } } #ifdef USE_LIBCURL // Update file's timestamp Common::HashMap<Common::String, uint32> timestamps = loadTimestamps(); timestamps[filename] = INVALID_TIMESTAMP; saveTimestamps(timestamps); #endif // Obtain node. SaveFileCache::const_iterator file = _saveFileCache.find(filename); Common::FSNode fileNode; // If the file did not exist before, we add it to the cache. if (file == _saveFileCache.end()) { const Common::FSNode savePath(savePathName); fileNode = savePath.getChild(filename); } else { fileNode = file->_value; } // Open the file for saving. Common::WriteStream *const sf = fileNode.createWriteStream(); Common::OutSaveFile *const result = new Common::OutSaveFile(compress ? Common::wrapCompressedWriteStream(sf) : sf); // Add file to cache now that it exists. _saveFileCache[filename] = Common::FSNode(fileNode.getPath()); return result; }
Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String &filename) { // Assure the savefile name cache is up-to-date. assureCached(getSavePath()); if (getError().getCode() != Common::kNoError) return nullptr; for (Common::StringArray::const_iterator i = _lockedFiles.begin(), end = _lockedFiles.end(); i != end; ++i) { if (filename == *i) { return nullptr; //file is locked, no loading available } } SaveFileCache::const_iterator file = _saveFileCache.find(filename); if (file == _saveFileCache.end()) { return nullptr; } else { // Open the file for loading. Common::SeekableReadStream *sf = file->_value.createReadStream(); return Common::wrapCompressedReadStream(sf); } }
Common::StringArray DefaultSaveFileManager::listSavefiles(const Common::String &pattern) { Common::String savePathName = getSavePath(); checkPath(Common::FSNode(savePathName)); if (getError().getCode() != Common::kNoError) return Common::StringArray(); // recreate FSNode since checkPath may have changed/created the directory Common::FSNode savePath(savePathName); Common::FSDirectory dir(savePath); Common::ArchiveMemberList savefiles; Common::StringArray results; Common::String search(pattern); if (dir.listMatchingMembers(savefiles, search) > 0) { for (Common::ArchiveMemberList::const_iterator file = savefiles.begin(); file != savefiles.end(); ++file) { results.push_back((*file)->getName()); } } return results; }
void MainLoop::eraseAutosave(Model* model) { remove(getSavePath(model, Model::GameType::AUTOSAVE).c_str()); }