QString QBattSysFSMethod::getPSUCapacityLevel() { if (checkFileExists(psu->battery.path, FILE_BATT_CAPACITY_LEVEL)) return getFileContents(psu->battery.path, FILE_BATT_CAPACITY_LEVEL); return RESPONSE_N_A; }
QString QBattSysFSMethod::getPSUManufacturer() { if (checkFileExists(psu->battery.path, FILE_BATT_MANUFACTURER)) return getFileContents(psu->battery.path, FILE_BATT_MANUFACTURER); return RESPONSE_N_A; }
QString QBattSysFSMethod::getPSUModelName() { if (checkFileExists(psu->battery.path, FILE_BATT_MODEL_NAME)) return getFileContents(psu->battery.path, FILE_BATT_MODEL_NAME); return RESPONSE_N_A; }
QString QBattSysFSMethod::getPSUTechnology() { if (checkFileExists(psu->battery.path, FILE_BATT_TECHNOLOGY)) return getFileContents(psu->battery.path, FILE_BATT_TECHNOLOGY); return RESPONSE_N_A; }
QString QBattSysFSMethod::getPSUType() { if (checkFileExists(psu->battery.path, PSU_FILE_TYPE)) return getFileContents(psu->battery.path, PSU_FILE_TYPE); return RESPONSE_N_A; }
QString QBattSysFSMethod::getPSUStatus() { if (checkFileExists(psu->battery.path, FILE_BATT_STATUS)) return getFileContents(psu->battery.path, FILE_BATT_STATUS); return RESPONSE_N_A; }
QString QBattSysFSMethod::getPSUSerialNumber() { if (checkFileExists(psu->battery.path, FILE_BATT_SERIAL_NUMBER)) return getFileContents(psu->battery.path, FILE_BATT_MANUFACTURER); return RESPONSE_N_A; }
QString QBattSysFSMethod::getACADName() { if (checkFileExists(psu->ac_adapter.path, PSU_FILE_TYPE)) return getFileContents(psu->ac_adapter.path, PSU_FILE_TYPE); return RESPONSE_N_A; }
bool QBattSysFSMethod::searchSysFs_Battery() { QDir searchDir(PSU_SYSTEM_PATH); QString path; if (!checkDirExists(PSU_SYSTEM_PATH)) return false; searchDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); QDirIterator qdi(searchDir, QDirIterator::Subdirectories); while (qdi.hasNext()) { path = qdi.next(); if (!(QString::compare(getFileContents(path, PSU_FILE_TYPE), DEF_BATTERY_TYPE, Qt::CaseSensitive))) { psu->battery.path = path; return true; } } // Initialize path with "none" psu->battery.path = PSU_SYSTEM_PATH_NONE; return false; }
bool Shader::loadFromFile(const std::string& compute) { #if defined ODIN_COMPUTE_SHADER // Create a program m_program = render::lib::createProgram(); // Read the files std::string computeShader; if (!getFileContents(compute, computeShader)) { LOG_ERROR("Failed to open Compute Shader file: %s", compute.c_str()); return false; } else LOG_INFO("Compute Shader successfully loaded: %s", compute.c_str()); bool success = false; if(addShader(computeShader, ODIN_COMPUTE_SHADER)) { // link program render::lib::linkProgram(m_program); if (!checkLinkErrors(m_program)) { render::lib::deleteProgram(m_program); m_program = 0; } success = true; } return success; #else LOG_ERROR("This system does not support Compute shaders"); return false; #endif }
bool Shader::loadFromFile(const std::string& vertex, const std::string& geometry, const std::string& fragment) { // Create a program m_program = render::lib::createProgram(); // Read the files std::string vertexShader; if (!getFileContents(vertex, vertexShader)) { LOG_ERROR("Failed to open Vertex Shader file: %s", vertex.c_str()); return false; } else LOG_INFO("Vertex Shader successfully loaded: %s", vertex.c_str()); std::string geometryShader; if (!getFileContents(geometry, geometryShader)) { LOG_ERROR("Failed to open Geometry Shader file: %s", geometry.c_str()); return false; } else LOG_INFO("Geometry Shader successfully loaded: %s", geometry.c_str()); std::string fragmentShader; if (!getFileContents(fragment, fragmentShader)) { LOG_ERROR("Failed to open Fragment Shader file: %s", fragment.c_str()); return false; } else LOG_INFO("Fragment Shader successfully loaded: %s", fragment.c_str()); bool success = false; if(addShader(vertexShader, ODIN_VERTEX_SHADER) && addShader(geometryShader, ODIN_GEOMETRY_SHADER) && addShader(fragmentShader, ODIN_FRAGMENT_SHADER)) { // link program render::lib::linkProgram(m_program); if (!checkLinkErrors(m_program)) { render::lib::deleteProgram(m_program); m_program = 0; } success = true; } return success; }
void appendFile(constr& file, constr& text) { str contents = getFileContents(file); contents += text; writeFileToDisk(file, contents); }
bool Shader::loadFromFile(const std::string &vertexShaderFilename, const std::string &fragmentShaderFilename) { std::vector<char> vertexShader; if (!getFileContents(vertexShaderFilename, vertexShader)) { std::cerr << "Failed to open shader file \"" << vertexShaderFilename << "\".\n"; return false; } std::vector<char> fragmentShader; if (!getFileContents(fragmentShaderFilename, fragmentShader)) { std::cerr << "Failed to open shader file \"" << fragmentShaderFilename << "\".\n"; return false; } return compile(&vertexShader[0], &fragmentShader[0]); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- QString PMFileGenerator::generateFileContents(QString replaceStr) { QString pluginName = getPluginName(); QString contents = getFileContents(replaceStr); return contents; }
JsonManagerRef JsonManager::create( const std::string &fileName ) { auto contents = getFileContents( fileName ); sJsonManager = JsonManagerRef( new JsonManager( fileName, contents ) ); sJsonManagerInitialized = true; CI_LOG_V("Created JsonManager"); return JsonManager::get(); }
void recursiveFillIncludedLuaFileNames(std::set<string>& mLuaScriptNames, const Path& mPackPath, const string& mLuaScript) { for(const auto& name : getIncludedLuaFileNames(mLuaScript)) { mLuaScriptNames.insert(name); recursiveFillIncludedLuaFileNames(mLuaScriptNames, mPackPath, getFileContents(mPackPath + "/Scripts/" + name)); } }
int QBattSysFSMethod::getPSUChargeFull() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_CHARGE_FULL)) ret = getFileContents(psu->battery.path, FILE_BATT_CHARGE_FULL).toInt(); return ret; }
void recursiveFillIncludedLuaFileNames(unordered_set<string>& mLuaScriptNames, const string& mPackPath, const string& mLuaScript) { unordered_set<string> current{getIncludedLuaFileNames(mLuaScript)}; for(const auto& name : current) { mLuaScriptNames.insert(name); recursiveFillIncludedLuaFileNames(mLuaScriptNames, mPackPath, getFileContents(mPackPath + "/Scripts/" + name)); } }
int QBattSysFSMethod::getPSUPresent() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_PRESENT)) ret = getFileContents(psu->battery.path, FILE_BATT_PRESENT).toInt(); return ret; }
int QBattSysFSMethod::getACADOnline() { int ret = -1; if (checkFileExists(psu->ac_adapter.path, FILE_ACAD_ONLINE)) ret = getFileContents(psu->ac_adapter.path, FILE_ACAD_ONLINE).toInt(); return ret; }
int QBattSysFSMethod::getPSUVoltageMinDesign() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_VOLTAGE_MIN_DESIGN)) ret = getFileContents(psu->battery.path, FILE_BATT_VOLTAGE_MIN_DESIGN).toInt(); return ret; }
int QBattSysFSMethod::getPSUCycleCount() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_CYCLE_COUNT)) ret = getFileContents(psu->battery.path, FILE_BATT_CYCLE_COUNT).toInt(); return ret; }
int QBattSysFSMethod::getPSUVoltageNow() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_VOLTAGE_NOW)) ret = getFileContents(psu->battery.path, FILE_BATT_VOLTAGE_NOW).toInt(); return ret; }
int QBattSysFSMethod::getPSUPowerNow() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_POWER_NOW)) ret = getFileContents(psu->battery.path, FILE_BATT_POWER_NOW).toInt(); return ret; }
int QBattSysFSMethod::getPSUCurrentNow() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_CURRENT_NOW)) ret = getFileContents(psu->battery.path, FILE_BATT_CURRENT_NOW).toInt(); return ret; }
int QBattSysFSMethod::getPSUCapacity() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_CAPACITY)) ret = getFileContents(psu->battery.path, FILE_BATT_CAPACITY).toInt(); return ret; }
TACommandVerdict getFileContents_cmd( TAThread thread, TAInputStream stream ) { char * fileName = readString( & stream ); char * result = getFileContents( fileName ); writeInt( thread, result == NULL ? 1 : 0 ); if ( result != NULL ) { writeString( thread, result ); } sendResponse( thread ); if ( result != NULL ) { ta_dealloc_memory( result ); } return taDefaultVerdict; }
int QBattSysFSMethod::getPSUEnergyFullDesign() { int ret = -1; if (checkFileExists(psu->battery.path, FILE_BATT_ENERGY_FULL_DESIGN)) ret = getFileContents(psu->battery.path, FILE_BATT_ENERGY_FULL_DESIGN).toInt(); return ret; }
void DiffEditorPlugin::diff() { QString fileName1 = QFileDialog::getOpenFileName(0, tr("Select First File for Diff"), QString()); if (fileName1.isNull()) return; QString fileName2 = QFileDialog::getOpenFileName(0, tr("Select Second File for Diff"), QString()); if (fileName2.isNull()) return; const Core::Id editorId = Constants::DIFF_EDITOR_ID; //: Editor title QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1).arg(fileName2); DiffEditor *editor = qobject_cast<DiffEditor *> (Core::EditorManager::openEditorWithContents(editorId, &title)); if (!editor) return; Core::EditorManager::activateEditor(editor); DiffEditorWidget *editorWidget = editor->editorWidget(); const QString text1 = getFileContents(fileName1, editorWidget->codec()); const QString text2 = getFileContents(fileName2, editorWidget->codec()); DiffEditorWidget::DiffFilesContents dfc; dfc.leftFileInfo = fileName1; dfc.leftText = text1; dfc.rightFileInfo = fileName2; dfc.rightText = text2; QList<DiffEditorWidget::DiffFilesContents> list; list.append(dfc); editor->setDiff(list); }
bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::string& fragmentShaderFilename) { // Read the vertex shader file std::vector<char> vertexShader; if (!getFileContents(vertexShaderFilename, vertexShader)) { err() << "Failed to open vertex shader file \"" << vertexShaderFilename << "\"" << std::endl; return false; } // Read the fragment shader file std::vector<char> fragmentShader; if (!getFileContents(fragmentShaderFilename, fragmentShader)) { err() << "Failed to open fragment shader file \"" << fragmentShaderFilename << "\"" << std::endl; return false; } // Compile the shader program return compile(&vertexShader[0], &fragmentShader[0]); }