static void OpenUsingDde(HWND targetWnd, const WCHAR *filePath, CommandLineInfo& i, bool isFirstWin) { // delegate file opening to a previously running instance by sending a DDE message WCHAR fullpath[MAX_PATH]; GetFullPathName(filePath, dimof(fullpath), fullpath, NULL); str::Str<WCHAR> cmd; cmd.AppendFmt(L"[" DDECOMMAND_OPEN L"(\"%s\", 0, 1, 0)]", fullpath); if (i.destName && isFirstWin) { cmd.AppendFmt(L"[" DDECOMMAND_GOTO L"(\"%s\", \"%s\")]", fullpath, i.destName); } else if (i.pageNumber > 0 && isFirstWin) { cmd.AppendFmt(L"[" DDECOMMAND_PAGE L"(\"%s\", %d)]", fullpath, i.pageNumber); } if ((i.startView != DM_AUTOMATIC || i.startZoom != INVALID_ZOOM || i.startScroll.x != -1 && i.startScroll.y != -1) && isFirstWin) { const WCHAR *viewMode = prefs::conv::FromDisplayMode(i.startView); cmd.AppendFmt(L"[" DDECOMMAND_SETVIEW L"(\"%s\", \"%s\", %.2f, %d, %d)]", fullpath, viewMode, i.startZoom, i.startScroll.x, i.startScroll.y); } if (i.forwardSearchOrigin && i.forwardSearchLine) { ScopedMem<WCHAR> sourcePath(path::Normalize(i.forwardSearchOrigin)); cmd.AppendFmt(L"[" DDECOMMAND_SYNC L"(\"%s\", \"%s\", %d, 0, 0, 1)]", fullpath, sourcePath, i.forwardSearchLine); } if (!i.reuseDdeInstance) { // try WM_COPYDATA first, as that allows targetting a specific window COPYDATASTRUCT cds = { 0x44646557 /* DdeW */, (DWORD)(cmd.Size() + 1) * sizeof(WCHAR), cmd.Get() }; LRESULT res = SendMessage(targetWnd, WM_COPYDATA, NULL, (LPARAM)&cds); if (res) return; } DDEExecute(PDFSYNC_DDE_SERVICE, PDFSYNC_DDE_TOPIC, cmd.Get()); }
static void OpenUsingDde(const TCHAR *filePath, CommandLineInfo& i, bool isFirstWin) { // delegate file opening to a previously running instance by sending a DDE message TCHAR fullpath[MAX_PATH]; GetFullPathName(filePath, dimof(fullpath), fullpath, NULL); ScopedMem<TCHAR> cmd(str::Format(_T("[") DDECOMMAND_OPEN _T("(\"%s\", 0, 1, 0)]"), fullpath)); DDEExecute(PDFSYNC_DDE_SERVICE, PDFSYNC_DDE_TOPIC, cmd); if (i.destName && isFirstWin) { cmd.Set(str::Format(_T("[") DDECOMMAND_GOTO _T("(\"%s\", \"%s\")]"), fullpath, i.destName)); DDEExecute(PDFSYNC_DDE_SERVICE, PDFSYNC_DDE_TOPIC, cmd); } else if (i.pageNumber > 0 && isFirstWin) { cmd.Set(str::Format(_T("[") DDECOMMAND_PAGE _T("(\"%s\", %d)]"), fullpath, i.pageNumber)); DDEExecute(PDFSYNC_DDE_SERVICE, PDFSYNC_DDE_TOPIC, cmd); } if ((i.startView != DM_AUTOMATIC || i.startZoom != INVALID_ZOOM || i.startScroll.x != -1 && i.startScroll.y != -1) && isFirstWin) { const TCHAR *viewMode = DisplayModeConv::NameFromEnum(i.startView); cmd.Set(str::Format(_T("[") DDECOMMAND_SETVIEW _T("(\"%s\", \"%s\", %.2f, %d, %d)]"), fullpath, viewMode, i.startZoom, i.startScroll.x, i.startScroll.y)); DDEExecute(PDFSYNC_DDE_SERVICE, PDFSYNC_DDE_TOPIC, cmd); } if (i.forwardSearchOrigin && i.forwardSearchLine) { ScopedMem<TCHAR> sourcePath(path::Normalize(i.forwardSearchOrigin)); cmd.Set(str::Format(_T("[") DDECOMMAND_SYNC _T("(\"%s\", \"%s\", %d, 0, 0, 1)]"), filePath, sourcePath, i.forwardSearchLine)); DDEExecute(PDFSYNC_DDE_SERVICE, PDFSYNC_DDE_TOPIC, cmd); } }
void CodeManager::createDirectories() { // check directory structure createDirectory(QDir(cpuPath())); createDirectory(QDir(sourcePath())); createDirectory(QDir(libPath())); createDirectory(QDir(incPath())); }
int CodeManager::compile() { // create arguments QStringList args = QStringList::split(' ', Settings::instance()->compilerCmd()); args.append(filename()); ProcessDialog *dialog = ProcessDialog::instance(); return dialog->run(sourcePath(), args); }
QString QmlObserverTool::toolByInstallData(const QString &qtInstallData) { if (!Core::ICore::instance()) return QString(); const QStringList directories = installDirectories(qtInstallData); const QStringList binFilenames = validBinaryFilenames(); return byInstallDataHelper(sourcePath(), sourceFileNames(), directories, binFilenames, false); }
bool CodeManager::edit() { QProcess *proc = new QProcess(); QStringList args = QStringList::split(' ', Settings::instance()->editorCmd()); args.append(filename()); proc->setArguments(args); proc->setWorkingDirectory(QDir(sourcePath())); return proc->launch(""); }
void FileTransfer::downloadFile(const std::string filepath) { std::string sourcePath(Plugin::GIT_CACHE_DIR); sourcePath.append("/").append(filepath); Process::Args args; args.push_back(filepath); // TODO: Change this name std::string targetPath("~/keshig-storage/"); targetPath.append(filepath); Poco::ProcessHandle ph = Process::launch("scp", args, 0, 0, 0); if (ph.wait() != 0) throw new Poco::RuntimeException("Failed to upload file"); }
/** * parses the selected path for files to upload **/ void MainWindow::processSelectedPath() { QDir sourcePath(ui->leGalleryPath->text()); sourcePath.setFilter(QDir::Files | QDir::NoDotAndDotDot); QStringList filters; filters << "*.jpg" << "*.jpeg" << "*.png" << "*.tiff"; // list of accepted files sourcePath.setNameFilters(filters); qDebug() << "reading content of directory: " << sourcePath.absolutePath(); QFileInfoList fileList = sourcePath.entryInfoList(); for(int i = 0; i < fileList.size(); i++) { m_pLPUploader->addEntryToUpload(fileList.at(i).absoluteFilePath()); qDebug() << "MainWindow::processSelectedPath: added " << fileList.at(i).absoluteFilePath(); } }
void testInfos(const char *className, const char *methodName, const char *classPath, const char *type_of_test, const char *language) { const std::string& module_name = sbf::pkg::Module::get( "vgd", "0-5" )->getName(); std::string module_description = sbf::pkg::Module::get()->getDescription(); boost::filesystem::path initial_path = boost::filesystem::current_path(); initial_path = initial_path.parent_path(); boost::filesystem::path sourcePath( initial_path / "include" / module_name / classPath ); TYPE_OF_TEST(type_of_test); TESTED_MODULE(module_name.c_str()); MODULE_DESCRIPTION(module_description.c_str()); TESTED_CLASS(className); TESTED_METHOD(methodName); TESTED_CLASSPATH(sourcePath.string().c_str()); LANGUAGE(language); }
string CViewRenderer::renderFile(const IRenderingContext * context, const string & sourceFile, CDT & data, bool ret) throw (CException) { boost::filesystem::path sourcePath(sourceFile); if (!boost::filesystem::exists(sourcePath)) { throw CException("View file \"" + sourceFile + "\" does not exist."); } string viewFile = getViewFile(sourceFile); boost::filesystem::path viewPath(viewFile); if (!boost::filesystem::exists(viewPath) || boost::filesystem::last_write_time(sourcePath) > boost::filesystem::last_write_time(viewPath)) { if (generateViewFile(sourceFile, viewFile)) { chmod(viewFile.c_str(), filePermission); } else { throw CException("Can't generate view file \"" + viewFile + "\" from source file \"" + sourceFile + "\"."); } } if (context != 0) { return context->renderInternal(viewFile, data, ret); } stringstream os; StreamOutputCollector outputCollector(os); TDynamicTemplateCacheMap::const_iterator found = _templateCache.find(viewFile); VMLoader * oLoader = 0; if (found == _templateCache.end()) { oLoader = new VMFileLoader(viewFile.c_str()); _templateCache[viewFile.c_str()] = boost::shared_ptr<VMLoader>(oLoader); } else { oLoader = found->second.get(); } PROFILE_BEGIN("CViewRenderer::rendering template bytecode of \"" + viewFile + "\"") UINT_32 iIP = 0; VM * vm = Cws::app()->getTemplateEngine()->getVM(); const VMMemoryCore * pVMMemoryCore = oLoader->GetCore(); vm->Init(pVMMemoryCore, &outputCollector, 0); vm->Run(pVMMemoryCore, &outputCollector, iIP, data, 0); PROFILE_END() if (ret) { return os.str(); } else { Cws::app()->getOutputStack().top()->echo(os.str()); return ""; } }
LRESULT SnapshotWizardPage1::OnWizardNext() { CAutoPtr<wchar_t> sourcePath(new wchar_t[sourceEdit_.GetWindowTextLengthW() + 1]); sourceEdit_.GetWindowTextW(sourcePath, sourceEdit_.GetWindowTextLengthW() + 1); CAutoPtr<wchar_t> destinationPath(new wchar_t[destinationEdit_.GetWindowTextLengthW() + 1]); destinationEdit_.GetWindowTextW(destinationPath, destinationEdit_.GetWindowTextLengthW() + 1); wchar_t expandedSourcePath[MAX_PATH]; wchar_t expandedDestinationPath[MAX_PATH]; if (0 == ::ExpandEnvironmentStrings(sourcePath, expandedSourcePath, MAX_PATH)) { ShowMessageBox(L"Bad source path format."); return -1; } if (0 == ::ExpandEnvironmentStrings(destinationPath, expandedDestinationPath, MAX_PATH)) { ShowMessageBox(L"Bad destination path format."); return -1; } if (!ATLPath::FileExists(expandedSourcePath)) { ShowMessageBox(L"The source file does not exists."); return -1; } if (ATLPath::FileExists(expandedDestinationPath)) { ShowMessageBox(L"The Destination file already exists."); return -1; } auto hr = Vss::CopyFileFromSnapshot(sourcePath, destinationPath); if (FAILED(hr)) { CString errorMessage; errorMessage.Format(L"%s : %d", L"Vss copy Failed.", hr); ShowMessageBox(errorMessage); return -1; } if (!InvokeEsentutilP(destinationPath)) { CString errorMessage; errorMessage.Format(L"%s : %d", L"Database repair Failed. : ", GetLastError()); ShowMessageBox(errorMessage); return -1; } wcscpy_s(sharedStringPage1_, MAX_PATH + 1, destinationPath); return 0; }
static WindowInfo *LoadOnStartup(const WCHAR *filePath, CommandLineInfo& i, bool isFirstWin) { LoadArgs args(filePath); args.showWin = !(i.printDialog && i.exitWhenDone) && !gPluginMode; WindowInfo *win = LoadDocument(args); if (!win) return win; if (win->IsDocLoaded() && i.destName && isFirstWin) { win->linkHandler->GotoNamedDest(i.destName); } else if (win->IsDocLoaded() && i.pageNumber > 0 && isFirstWin) { if (win->ctrl->ValidPageNo(i.pageNumber)) win->ctrl->GoToPage(i.pageNumber, false); } if (i.hwndPluginParent) MakePluginWindow(*win, i.hwndPluginParent); if (!win->IsDocLoaded() || !isFirstWin) return win; if (i.enterPresentation || i.enterFullScreen) { if (i.enterPresentation && win->isFullScreen || i.enterFullScreen && win->presentation) ExitFullScreen(*win); EnterFullScreen(*win, i.enterPresentation); } if (i.startView != DM_AUTOMATIC) SwitchToDisplayMode(win, i.startView); if (i.startZoom != INVALID_ZOOM) ZoomToSelection(win, i.startZoom); if ((i.startScroll.x != -1 || i.startScroll.y != -1) && win->AsFixed()) { DisplayModel *dm = win->AsFixed(); ScrollState ss = dm->GetScrollState(); ss.x = i.startScroll.x; ss.y = i.startScroll.y; dm->SetScrollState(ss); } if (i.forwardSearchOrigin && i.forwardSearchLine && win->AsFixed() && win->AsFixed()->pdfSync) { UINT page; Vec<RectI> rects; ScopedMem<WCHAR> sourcePath(path::Normalize(i.forwardSearchOrigin)); int ret = win->AsFixed()->pdfSync->SourceToDoc(sourcePath, i.forwardSearchLine, 0, &page, rects); ShowForwardSearchResult(win, sourcePath, i.forwardSearchLine, 0, ret, page, rects); } return win; }
QString QmlObserverTool::copy(const QString &qtInstallData, QString *errorMessage) { const QStringList directories = installDirectories(qtInstallData); // Try to find a writable directory. foreach (const QString &directory, directories) { if (!mkpath(directory, errorMessage)) continue; errorMessage->clear(); if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) { errorMessage->clear(); return directory; } } *errorMessage = QCoreApplication::translate("ProjectExplorer::QmlObserverTool", "QMLObserver could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); }
QString QmlDebuggingLibrary::copy(const QString &qtInstallData, QString *errorMessage) { const QStringList directories = QmlDebuggingLibrary::installDirectories(qtInstallData); // Try to find a writeable directory. foreach (const QString &directory, directories) { if (!mkpath(directory, errorMessage)) { continue; } else { errorMessage->clear(); } if (copyFiles(sourcePath(), sourceFileNames(), directory, errorMessage)) { errorMessage->clear(); return directory; } } *errorMessage = QCoreApplication::translate("Qt4ProjectManager::QmlDebuggingLibrary", "QML Debugging library could not be built in any of the directories:\n- %1\n\nReason: %2") .arg(directories.join(QLatin1String("\n- ")), *errorMessage); return QString(); }
void SchemaValue::getAllowedValues(std::vector<AllowedValue> &allowedValues, const std::shared_ptr<const EnvironmentNode> &pEnvNode) const { // // If enumerated, get the allowed values if (m_pType->isEnumerated()) { allowedValues = m_pType->getEnumeratedValues(); } // // Is there a specialized rule that limits the values? The order is important here. Place more restrictive rules first. Note also that // a rule could be used inside a unique value set which should remain the last entry in this if then else if block // // uniqueItemType_espBinding - value is based on a unique item type described by the data for the rule. This is version 1 else if (m_valueLimitRuleType == "uniqueItemType_espBinding") { std::vector<std::string> params = splitString(m_valueLimitRuleData, ","); if (params.size() != 2) { std::string msg = "Applying rule " + m_valueLimitRuleType + ", expected 2 parameters in rule data"; throw(ParseException(msg)); } // // First parameter is the source values for an attribute search. The two parts of the parameter are the path to the // node set where the atttribute, the second part, name is found (not that there may be no entries). Find all the nodes // for the path (parts[0]), then get all of the values for the attribute (parts[1]). This serves as the list of existing // values that are eliminated from the final list of allowable values. ConfigPath sourcePath(params[0]); std::shared_ptr<ConfigPathItem> pSourcePath = sourcePath.getNextPathItem(); std::vector<std::shared_ptr<EnvironmentNode>> existingSourceNodes; pEnvNode->fetchNodes(pSourcePath->getElementName(), existingSourceNodes); std::vector<std::string> existingSourceAttributeValues; for (auto &existingNodeIt: existingSourceNodes) { existingSourceAttributeValues.push_back( existingNodeIt->getAttributeValue(pSourcePath->getAttributeName())); } // // Get the full set of possible values using the params[1] values. From its parts, parts[0] is the path // to find the set of all possible nodes that could serve as an allowable value. std::vector<std::shared_ptr<EnvironmentNode>> allSourceNodes; ConfigPath valuesPath(params[1]); std::shared_ptr<ConfigPathItem> pValuesPath = valuesPath.getNextPathItem(); std::string sourceAttributeName = pValuesPath->getAttributeName(); // for use below in case parts is reused later pEnvNode->fetchNodes(pValuesPath->getElementName(), allSourceNodes); // // For each exising source node, using the existingSourceAttributeValues, matching the name to the value in // sourceAttributeName, and collect the itemType values found. std::vector<std::string> existingItemTypes; for (auto &existingValueIt: existingSourceAttributeValues) { std::vector<std::shared_ptr<EnvironmentNode>>::iterator sourceIt = std::find_if(allSourceNodes.begin(), allSourceNodes.end(), [&](std::shared_ptr<EnvironmentNode> &srcIt) { return srcIt->getAttributeValue(sourceAttributeName) == existingValueIt; }); if (sourceIt != allSourceNodes.end()) { existingItemTypes.push_back((*sourceIt)->getSchemaItem()->getItemType()); } } // // Build the allowable value list by only adding itmes from the all sources list that don't hvae // an entry in the existing item type vector for (auto &sourceIt: allSourceNodes) { std::vector<std::string>::const_iterator itemTypeIt = std::find_if(existingItemTypes.begin(), existingItemTypes.end(), [&](const std::string &itemIt) { return itemIt == sourceIt->getSchemaItem()->getItemType(); }); if (itemTypeIt == existingItemTypes.end()) { allowedValues.push_back({ sourceIt->getAttributeValue(sourceAttributeName), "" }); } } } // // Or, keyed? (note that the keyed check MUST be last since a more restrictive rule may be defined for UI purposes // while a keyed reference is present for XML schema validation) else if (isFromUniqueValueSet()) { std::vector<std::string> refValues; getAllKeyRefValues(refValues); for (auto it = refValues.begin(); it != refValues.end(); ++it) { allowedValues.push_back({ *it, "" }); } if (!allowedValues.empty() && m_valueLimitRuleType == "addDependencies_FromSiblingAttributeValue") { std::vector<std::string> params = splitString(m_valueLimitRuleData, ","); if (params.size() != 2) { std::string msg = "Applying rule " + m_valueLimitRuleType + ", expected 4 parameters in rule data"; throw(ParseException(msg)); } std::string matchPath = params[0]; std::string matchAttribute = params[1]; std::string depAttrSource = params[2]; std::string depAttrTarget = params[3]; // // Get an environment node pointer using the first entry in the env values vector. We know it's not empty because // we have at least one allowed value. Use this for fetching std::shared_ptr<EnvironmentNode> pEnvNode = m_envValues[0].lock()->getEnvironmentNode(); // // Loop through each allowed value and find it's environment node (by value). Then add a dependency // based on the dependent attribute source. for (auto &allowedValue: allowedValues) { std::string path = matchPath + "[@" + matchAttribute + "='" + allowedValue.m_value + "']"; std::vector<std::shared_ptr<EnvironmentNode>> envNodes; pEnvNode->fetchNodes(path, envNodes); if (!envNodes.empty()) { std::shared_ptr<EnvironmentValue> pAttr = envNodes[0]->getAttribute(depAttrSource); if (pAttr) { allowedValue.addDependentValue(depAttrTarget, pAttr->getValue()); } } } } } }
int RawConverter::parseArguments( int argc, char** argv ) { try // command line parsing { po::options_description options( std::string( "eVolveConverter - eVolve file converter " ) + QUOTE( EQUALIZER_VERSION ) ); bool showHelp(false); double scaleX = 1.0; double scaleY = 1.0; double scaleZ = 1.0; bool recalcDerivates(false); bool cmpRawDerivVhf(false); bool dscToVhf(false); bool savToVhf(false); bool derToRaw(false); bool rawToRaw(false); bool pvmToRaw(false); std::string sourcePath(""); std::string destinationPath(""); options.add_options() ( "help,h", po::bool_switch(&showHelp)->default_value(false), "produce help message" ) ( "sW", po::value<double>(&scaleX), "scale factor for width") ( "sH", po::value<double>(&scaleY), "scale factor for height" ) ( "sD", po::value<double>(&scaleZ), "scale factor for depth" ) ( "sA", po::value<double>(), "common scale factor") ( "rec,e", po::bool_switch(&recalcDerivates)->default_value(false), "recalculate derivatives in raw+der") ( "cmp,m", po::bool_switch(&cmpRawDerivVhf)->default_value(false), "compare raw+derivations+vhf") ( "dsc,c", po::bool_switch(&dscToVhf)->default_value(false), "dsc -> vhf file converter") ( "sav,v", po::bool_switch(&savToVhf)->default_value(false), "sav -> vhf transfer function converter") ( "der,r", po::bool_switch(&derToRaw)->default_value(false), "raw -> raw+derivatives") ( "raw,w", po::bool_switch(&rawToRaw)->default_value(false), "raw+derivatives -> raw") ( "pvm,p", po::bool_switch(&pvmToRaw)->default_value(false), "pvm[+sav] -> raw+derivatives+vhf" ) ( "dst,d", po::value<std::string>(&destinationPath), "destination file, e.g. Bucky32x32x32_d.raw" ) ( "src,s", po::value<std::string>(&sourcePath), "source file, e.g. Bucky32x32x32.raw" ); //parse program options po::variables_map variableMap; po::store( po::parse_command_line( argc, argv, options ), variableMap ); po::notify( variableMap ); if (showHelp) { std::cout << options << std::endl; return EXIT_SUCCESS; } if ( variableMap.count( "dst" ) != 1 ) throw std::runtime_error( "You must specify one destination path" ); if ( variableMap.count( "src" ) != 1 ) throw std::runtime_error( "You must specify a source path" ); if( rawToRaw ) // raw + derivatives -> raw return RawConverter::RawPlusDerivativesToRawConverter( sourcePath, destinationPath ); if( derToRaw ) // raw -> raw + derivatives return RawConverter::RawToRawPlusDerivativesConverter( sourcePath, destinationPath ); if( savToVhf ) // sav -> vhf return RawConverter::SavToVhfConverter( sourcePath, destinationPath ); if( dscToVhf ) // dsc -> vhf return RawConverter::DscToVhfConverter( sourcePath, destinationPath ); if( pvmToRaw ) // pvm -> raw return RawConverter::PvmSavToRawDerVhfConverter( sourcePath, destinationPath ); if( cmpRawDerivVhf ) // cmp raw+derivations+vhf return RawConverter::CompareTwoRawDerVhf( sourcePath, destinationPath ); if( recalcDerivates ) // recalculate derivatives return RawConverter::RecalculateDerivatives( sourcePath, destinationPath ); // Scale model if ( variableMap.count("sA") == 1 ) { double scaleVal = variableMap["sA"].as<double>(); if (variableMap.count("sW") == 0) scaleX = scaleVal; if (variableMap.count("sH") == 0) scaleY = scaleVal; if (variableMap.count("sD") == 0) scaleZ = scaleVal; } if ( ( variableMap.count("sW") + variableMap.count("sH") + variableMap.count("sD") + variableMap.count("sA") ) >= 1 ) { // At least one scale parameter is set, so scale... return RawConverter::ScaleRawDerFile( sourcePath, destinationPath, scaleX, scaleY, scaleZ ); } throw std::runtime_error("Converter options were not specified completely."); } catch( std::exception& exception ) { std::cerr << "Command line parse error: " << exception.what() << std::endl; return EXIT_FAILURE; } return EXIT_SUCCESS; }
QStringList QmlObserverTool::sourceFileNames() { return recursiveFileList(QDir(sourcePath())); }
string CViewRenderer::getViewFile(const string & file) { boost::filesystem::path sourcePath(file); return sourcePath.parent_path().string() + "/" + boost::filesystem::basename(sourcePath) + ".ct2"; }
void Foam::multiSolver::setInitialSolverDomain(const word& solverDomainName) { if (!solverDomains_.found(solverDomainName)) { FatalErrorIn("multiSolver::setInitialSolverDomain") << "Initial solverDomainName '" << solverDomainName << "' does" << " not exist in multiSolver dictionary. Found entries are: " << solverDomains_.toc() << abort(FatalError); } currentSolverDomain_ = solverDomainName; setSolverDomainControls(currentSolverDomain_); // Purge all time directories from case directory root purgeTimeDirs(multiDictRegistry_.path()); // Purge any constant/superLoopData/ fileName superLoopDataPath ( multiDictRegistry_.path()/multiDictRegistry_.constant() /"superLoopData" ); if (exists(superLoopDataPath)) { rmDir(superLoopDataPath); } // Read initial settings and determine data source (from which path the // initial data is copied, the starting superLoop_, and the current // globalTime (used to determine globalOffset). Rules that are applied: // // 1. superLoop_ = data source superLoop // a. unless data source solverDomain != currentSolverDomain_, in // which case, superLoop_ = data source superLoop + 1 // 2. globalTime = data source globalTime. globalTime does not increment // when swapping solver domains. // 3. startTime = data source local time // a. unless data source solverDomain != currentSolverDomain_, in // which case, startTime is dictated by the solverDomains // subdictionary. // 4. endTime is determined by the solverDomains subdictionary // a. unless the finalStopAt trumps it // Find initial data source timeCluster tcSource(initialDataSource()); fileName sourcePath(findInstancePath(tcSource, tcSource.size() - 1)); superLoop_ = tcSource.superLoop(); globalIndex_ = tcSource.globalIndex(); // If starting from initial conditions, superLoop_ = -1 if (superLoop_ < 0) superLoop_ = 0; scalar globalTime(tcSource.globalValue(tcSource.size() - 1)); scalar localStartTime(tcSource.localValue(tcSource.size() -1)); // Now to apply the exceptions if currentSolverDomain_ != data source // solverDomain (see long comment above). if (sourcePath.path().path().name() != currentSolverDomain_) { superLoop_++; globalIndex_++; switch (startFrom_) { case mtsFirstTime: localStartTime = 0; break; case mtsStartTime: localStartTime = startTime_; break; case mtsLatestTimeThisDomain: { timeCluster tcTemp ( findLatestLocalTime ( readSolverDomainTimes(currentSolverDomain_) ) ); localStartTime = tcTemp.localValue(0); } break; case mtsLatestTimeAllDomains: localStartTime = globalTime; break; } } startTime_ = localStartTime; globalTimeOffset_ = globalTime - startTime_; // Give multiDictRegistry a time value (required for regIOobject::write() // to case/[timeValue] multiDictRegistry_.setTime(startTime_, 0); // Copy the source data and any previous time directories to // case/[localTime] forAll(tcSource, i) { fileName copyMe(findInstancePath(tcSource, i)); cp(copyMe, multiDictRegistry_.path()); }
Project * App::CreateNewProject(const BMessage &settings) { Project *proj = NULL; BString projectName, targetName, projectPath, templateName, pldName; int32 projectType, scmType; bool createFolder, populateProject = true; settings.FindString("name",&projectName); settings.FindString("target",&targetName); settings.FindInt32("type",&projectType); settings.FindString("path",&projectPath); settings.FindInt32("scmtype", &scmType); settings.FindBool("createfolder",&createFolder); settings.FindString("template", &templateName); settings.FindString("pldfile", &pldName); if (templateName.CountChars() > 0) { // Templates are now a directory with a TEMPLATEINFO file. All files in the // directory are copies, allowing for much greater flexibility than before. BString projectFileName(projectName); projectFileName << ".pld"; DPath templatePath(gAppPath.GetFolder()); templatePath << "Templates" << templateName; // Copy the contents of the chosen template folder to the project path DPath sourcePath(templatePath); DPath destPath(gProjectPath); if (createFolder) { destPath << projectName; create_directory(destPath.GetFullPath(), 0700); } BString wildcard("'"); wildcard << sourcePath.GetFullPath() << "'/*"; ShellHelper shell("cp -a "); shell << wildcard; shell.AddQuotedArg(destPath.GetFullPath()); shell.Run(); // The copy command copies *everything*, so we have to delete the // TEMPLATEINFO file. DPath templateInfo(destPath); templateInfo << "TEMPLATEINFO"; BEntry infoEntry(templateInfo.GetFullPath()); infoEntry.Remove(); infoEntry.Unset(); DPath finalPath; // Load project and set info or create one, if needed. // If the settings contain the name of a .pld project file, we'll search // for that first. Assuming that it exists, we'll rename that file to the // project name specified. If it doesn't exist or the .pld name is empty, // we'll create a new project with the appropriate name. // The pldname field comes from the TEMPLATEINFO file, which can designate // the main project file in a template. This allows a template to have // multiple project files, such as for the Tracker Add-on development framework // which has both a project file for generating the actual addon and another // one which is the testing framework. bool createProjFile = true; if (pldName.CountChars() > 0) { // If a .pld project file was specified in TEMPLATEINFO, check to see if // the file exists and rename it. If it doesn't exist, we'll create a new // file, and if a .pld file already exists with the intended name, we won't // do anything except tell the user what's happened. DPath oldPldNamePath(destPath); oldPldNamePath << pldName; BEntry oldPldNameEntry(oldPldNamePath.GetFullPath()); DPath newPldNamePath(destPath); newPldNamePath << projectFileName; BEntry newPldNameEntry(newPldNamePath.GetFullPath()); if (newPldNameEntry.Exists()) { // createProjFile is false here only if there is a .pld file with the // user's chosen project name. If that is the case, we keep both files and // let the user sort it out. BString errMsg = B_TRANSLATE( "Project file '%projectname%.pld' already exists. The " "original file for this template is '%pldname%'. You'll need " "to open the project folder and figure out which one you wish to keep."); errMsg.ReplaceFirst("%projectname%", projectName); errMsg.ReplaceFirst("%pldname%", pldName); ShowAlert(errMsg); populateProject = createProjFile = false; finalPath = newPldNamePath; } else if (oldPldNameEntry.Exists()) { oldPldNameEntry.Rename(projectFileName.String()); populateProject = createProjFile = false; finalPath = newPldNamePath; } } if (createProjFile) { proj = Project::CreateProject(projectName.String(), targetName.String(), projectType, projectPath.String(), createFolder); if (proj) finalPath = proj->GetPath(); } else { proj = new Project(); if (proj->Load(finalPath.GetFullPath()) != B_OK) { delete proj; return NULL; } } } else { // This case is for stuff like the Quick Import feature proj = Project::CreateProject(projectName.String(), targetName.String(), projectType, projectPath.String(), createFolder); } if (!proj) return NULL; scm_t detectedSCM = DetectSCM(projectPath); proj->SetSourceControl(detectedSCM == SCM_NONE ? (scm_t)scmType : detectedSCM); gCurrentProject = proj; gProjectList->Lock(); gProjectList->AddItem(proj); gProjectList->Unlock(); BRect r(0,0,200,300); /* r.OffsetTo(gProjectWindowPoint); gProjectWindowPoint.x += 25; gProjectWindowPoint.y += 25; if (gProjectWindowPoint.x < 0) gProjectWindowPoint.x = 0; if (gProjectWindowPoint.y < 0) gProjectWindowPoint.y - 0; */ ProjectWindow *projwin = new ProjectWindow(r,gCurrentProject); projwin->Show(); BEntry entry(gCurrentProject->GetPath().GetFullPath()); if (entry.InitCheck() == B_OK) { entry_ref newprojref; entry.GetRef(&newprojref); UpdateRecentItems(newprojref); } if (populateProject) { entry_ref addRef; int32 i = 0; while (settings.FindRef("libs",i++,&addRef) == B_OK) { if (BEntry(&addRef).Exists()) proj->AddLibrary(DPath(addRef).GetFullPath()); } i = 0; BMessage addMsg(M_IMPORT_REFS); while (settings.FindRef("refs",i++,&addRef) == B_OK) addMsg.AddRef("refs",&addRef); PostToProjectWindow(&addMsg,NULL); } return proj; }
void ProjectGenerator::OnGenerateButton(const nuiEvent& rEvent) { nglString source = mpNuiSource->GetText(); nglString target = mpProjectTarget->GetText(); source.Trim(); target.Trim(); if ((source == nglString::Null) || (target == nglString::Null)) { nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), _T("Project Creator"), _T("source and target information can't be empty!"), eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } nglPath sourcePath(source); if (!sourcePath.Exists()) { nglString msg; msg.Format(_T("the nui source directory '%ls' does not exist!"), sourcePath.GetChars()); nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } if (!mNuiCheckProjectFile || !mNuiCheckTools) { nglString msg; msg.Format(_T("Parts of nui could not be found.\nCheck the nui source directory or checkout the complete nui sources from libnui.net!")); nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } mNuiSourcePath = source; mProjectTargetPath = target; nglPath path = nglPath(target); mProjectName = path.GetNodeName(); nglPath targetPath(target); nglString xcodeproj = mProjectName + _T(".xcodeproj"); targetPath += nglPath(xcodeproj); if (targetPath.Exists()) { nglString msg; msg.Format(_T("the following project exists already!\n'%ls'"), targetPath.GetChars()); nuiMessageBox* pMessageBox = new nuiMessageBox(GetMainWindow(), nglString(_T("Project Creator")), msg, eMB_OK); pMessageBox->QueryUser(); rEvent.Cancel(); return; } GetPreferences().Save(); Make(); rEvent.Cancel(); }
void ReflectionParser::GenerateFiles(void) { fs::path sourceRootDirectory( m_options.sourceRoot ); fs::path outputFileDirectory( m_options.outputModuleFileDirectory ); m_moduleFileHeaderTemplate = LoadTemplate( kTemplateModuleFileHeader ); if (!m_moduleFileHeaderTemplate.isValid( )) { std::stringstream error; error << "Unable to compile module file header template." << std::endl; error << m_moduleFileHeaderTemplate.errorMessage( ); throw std::exception( error.str( ).c_str( ) ); } m_moduleFileSourceTemplate = LoadTemplate( kTemplateModuleFileSource ); if (!m_moduleFileSourceTemplate.isValid( )) { std::stringstream error; error << "Unable to compile module file source template." << std::endl; error << m_moduleFileSourceTemplate.errorMessage( ); throw std::exception( error.str( ).c_str( ) ); } TemplateData moduleFilesData { TemplateData::Type::List }; fs::path metaCacheFileName = m_options.outputModuleFileDirectory; metaCacheFileName /= ".meta-cache"; auto metaCacheFileExists = exists( metaCacheFileName ); std::string moduleFileCache; for (auto &file : m_moduleFiles) { fs::path filePath( file.first ); // path relative to the source root auto relativeDir = utils::MakeRelativePath( sourceRootDirectory, filePath ) .replace_extension( "" ).string( ); if (relativeDir.find_first_of( ".." ) != std::string::npos) continue; auto outputFile = outputFileDirectory / relativeDir; auto outputFileHeader = change_extension( outputFile, "Generated.h" ); auto outputFileSource = change_extension( outputFile, "Generated.cpp" ); // module file name file.second.name = boost::regex_replace( relativeDir, kSpecialCharsRegex, "_" ); moduleFileCache += file.second.name + '\n'; TemplateData moduleFileData { TemplateData::Type::Object }; moduleFileData[ "name" ] = file.second.name; moduleFileData[ "header" ] = outputFileHeader.string( ); moduleFilesData << moduleFileData; // if the generated file header doesn't exist, we need to regenerate if (m_options.forceRebuild || !metaCacheFileExists || !exists( outputFileHeader )) { generateModuleFile( outputFileHeader, outputFileSource, file.first, file.second ); continue; } auto lastSourceWrite = last_write_time( filePath ); auto lastGeneratedWrite = last_write_time( outputFileHeader ); // if the generated file is older than the source file, we need to regenerate if (lastSourceWrite > lastGeneratedWrite) generateModuleFile( outputFileHeader, outputFileSource, file.first, file.second ); } fs::path moduleCacheFileName = m_options.outputModuleFileDirectory; moduleCacheFileName /= ".meta-cache"; if (!m_options.forceRebuild && metaCacheFileExists) { std::ifstream cacheFile( moduleCacheFileName.string( ) ); std::istreambuf_iterator<char> cacheFileBegin( cacheFile ); std::istreambuf_iterator<char> cacheFileEnd( nullptr ); // the cache is the same, so we don't need to write the source files if (utils::RangeEqual( moduleFileCache.begin( ), moduleFileCache.end( ), cacheFileBegin, cacheFileEnd )) { return; } } // update the cache utils::WriteText( moduleCacheFileName.string( ), moduleFileCache ); // module source file { auto sourceTemplate = LoadTemplate( kTemplateModuleSource ); if (!sourceTemplate.isValid( )) { std::stringstream error; error << "Unable to compile module source template." << std::endl; error << sourceTemplate.errorMessage( ); throw std::exception( error.str( ).c_str( ) ); } TemplateData sourceData { TemplateData::Type::Object }; addGlobalTemplateData( sourceData ); sourceData[ "moduleFile" ] = moduleFilesData; COMPILE_TYPE_TEMPLATES( sourceData, "external", m_externals ); fs::path sourcePath( m_options.outputModuleSource ); fs::create_directory( sourcePath.parent_path( ) ); utils::WriteText( sourcePath.string( ), sourceTemplate.render( sourceData ) ); } }
QString CodeManager::sourceFilePath(QString extension) { return QString("%1/%2") .arg(sourcePath()) .arg(filename(extension)); }
static QStringList sourceFileNames() { return recursiveFileList(QDir(sourcePath()), QString()); }
void CState::HandleDroppedFiles(const wxFileDataObject* pFileDataObject, const CLocalPath& path, bool copy) { const wxArrayString &files = pFileDataObject->GetFilenames(); if (!files.Count()) return; #ifdef __WXMSW__ int len = 1; for (unsigned int i = 0; i < files.Count(); i++) len += files[i].Len() + 1; // SHFILEOPSTRUCT's pTo and pFrom accept null-terminated lists // of null-terminated filenames. wxChar* from = new wxChar[len]; wxChar* p = from; for (unsigned int i = 0; i < files.Count(); i++) { wxStrcpy(p, files[i]); p += files[i].Len() + 1; } *p = 0; // End of list wxChar* to = new wxChar[path.GetPath().Len() + 2]; wxStrcpy(to, path.GetPath()); to[path.GetPath().Len() + 1] = 0; // End of list SHFILEOPSTRUCT op = {0}; op.pFrom = from; op.pTo = to; op.wFunc = copy ? FO_COPY : FO_MOVE; op.hwnd = (HWND)m_pMainFrame->GetHandle(); SHFileOperation(&op); delete [] to; delete [] from; #else for (unsigned int i = 0; i < files.Count(); i++) { const wxString& file(files[i]); wxLongLong size; bool is_link; CLocalFileSystem::local_fileType type = CLocalFileSystem::GetFileInfo(file, is_link, &size, 0, 0); if (type == CLocalFileSystem::file) { wxString name; CLocalPath sourcePath(file, &name); if (name.empty()) continue; if (copy) wxCopyFile(file, path.GetPath() + name); else wxRenameFile(file, path.GetPath() + name); } else if (type == CLocalFileSystem::dir) { if (copy) RecursiveCopy(CLocalPath(file), path); else { CLocalPath sourcePath(file); if (!sourcePath.HasParent()) continue; wxRenameFile(file, path.GetPath() + sourcePath.GetLastSegment()); } } } #endif RefreshLocal(); }
void CState::HandleDroppedFiles(const wxFileDataObject* pFileDataObject, const CLocalPath& path, bool copy) { const wxArrayString &files = pFileDataObject->GetFilenames(); if (!files.Count()) return; #ifdef __WXMSW__ int len = 1; for (unsigned int i = 0; i < files.Count(); i++) len += files[i].Len() + 1; // SHFILEOPSTRUCT's pTo and pFrom accept null-terminated lists // of null-terminated filenames. wxChar* from = new wxChar[len]; wxChar* p = from; for (unsigned int i = 0; i < files.Count(); i++) { wxStrcpy(p, files[i]); p += files[i].Len() + 1; } *p = 0; // End of list wxChar* to = new wxChar[path.GetPath().Len() + 2]; wxStrcpy(to, path.GetPath()); to[path.GetPath().Len() + 1] = 0; // End of list SHFILEOPSTRUCT op = {0}; op.pFrom = from; op.pTo = to; op.wFunc = copy ? FO_COPY : FO_MOVE; op.hwnd = (HWND)m_pMainFrame->GetHandle(); SHFileOperation(&op); delete [] to; delete [] from; #else wxString error; for (unsigned int i = 0; i < files.Count(); i++) { const wxString& file(files[i]); int64_t size; bool is_link; CLocalFileSystem::local_fileType type = CLocalFileSystem::GetFileInfo(file, is_link, &size, 0, 0); if (type == CLocalFileSystem::file) { wxString name; CLocalPath sourcePath(file, &name); if (name.empty()) continue; wxString target = path.GetPath() + name; if (file == target) continue; if (copy) wxCopyFile(file, target); else wxRenameFile(file, target); } else if (type == CLocalFileSystem::dir) { CLocalPath sourcePath(file); if (sourcePath == path || sourcePath.GetParent() == path) continue; if (sourcePath.IsParentOf(path)) { error = _("A directory cannot be dragged into one of its subdirectories."); continue; } if (copy) RecursiveCopy(sourcePath, path); else { if (!sourcePath.HasParent()) continue; wxRenameFile(file, path.GetPath() + sourcePath.GetLastSegment()); } } } if (!error.empty()) wxMessageBoxEx(error, _("Could not complete operation")); #endif RefreshLocal(); }
QStringList QmlDebuggingLibrary::sourceFileNames() { return recursiveFileList(QDir(sourcePath())); }