本文整理汇总了C++中FileName::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::toString方法的具体用法?C++ FileName::toString怎么用?C++ FileName::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: findQtInstallPath
// Find Qt installation by running qmake
static QString findQtInstallPath(const FileName &qmakePath)
{
if (qmakePath.isEmpty())
return QString();
QProcess proc;
QStringList args;
args.append(QLatin1String("-query"));
args.append(QLatin1String("QT_INSTALL_HEADERS"));
proc.start(qmakePath.toString(), args);
if (!proc.waitForStarted()) {
qWarning("%s: Cannot start '%s': %s", Q_FUNC_INFO, qPrintable(qmakePath.toString()),
qPrintable(proc.errorString()));
return QString();
}
proc.closeWriteChannel();
if (!proc.waitForFinished()) {
SynchronousProcess::stopProcess(proc);
qWarning("%s: Timeout running '%s'.", Q_FUNC_INFO, qPrintable(qmakePath.toString()));
return QString();
}
if (proc.exitStatus() != QProcess::NormalExit) {
qWarning("%s: '%s' crashed.", Q_FUNC_INFO, qPrintable(qmakePath.toString()));
return QString();
}
const QByteArray ba = proc.readAllStandardOutput().trimmed();
QDir dir(QString::fromLocal8Bit(ba));
if (dir.exists() && dir.cdUp())
return dir.absolutePath();
return QString();
}
示例2: getPortInfo
static PortInfo getPortInfo(const FileName & filename){
PortInfo info;
const auto parts = split(filename.getFile(),':');
info.portName = parts.empty() ? "" : parts[0];
#ifdef _WIN32
info.internalPortName = "\\\\.\\" + info.portName;
#else
info.internalPortName = info.portName;
#endif
info.baudRate = 9600;
info.bytesize = serial::eightbits;
info.stopbits = serial::stopbits_one;
info.flowcontrol = serial::flowcontrol_none;
info.parity = serial::parity_none;
for(auto& s:parts)
// std::cout << ">"<<s<<"\n";
if(parts.size()>1){
info.baudRate = StringUtils::toNumber<uint32_t>(parts[1]);
if(parts.size()>2){
switch(StringUtils::toNumber<uint32_t>(parts[2])){
case 5: info.bytesize = serial::fivebits; break;
case 6: info.bytesize = serial::sixbits; break;
case 7: info.bytesize = serial::sevenbits; break;
case 0:// empty -> default
case 8: info.bytesize = serial::eightbits; break;
default:
throw std::invalid_argument("SerialProvider: invalid bytesize :"+filename.toString());
}
if(parts.size()<=3 || parts[3].empty() || parts[3]=="n"){
info.parity = serial::parity_none;
}else if(parts[3]=="o"){
info.parity = serial::parity_odd;
}else if(parts[3]=="e"){
info.parity = serial::parity_even;
}else{
throw std::invalid_argument("SerialProvider: invalid parity :"+filename.toString());
}
if(parts.size()<=4 || parts[4].empty() || parts[4]=="1"){
info.stopbits = serial::stopbits_one;
}else if(parts[4]=="2"){
info.stopbits = serial::stopbits_two;
}else{
throw std::invalid_argument("SerialProvider: invalid stopbits :"+filename.toString());
}
if(parts.size()<=5 || parts[5].empty() || parts[5]=="n"){
info.flowcontrol = serial::flowcontrol_none;
}else if(parts[5]=="h"){
info.flowcontrol = serial::flowcontrol_hardware;
}else if(parts[5]=="s"){
info.flowcontrol = serial::flowcontrol_software;
}else{
throw std::invalid_argument("SerialProvider: invalid flowcontrol :"+filename.toString());
}
}
}
return info;
}
示例3: Node
DirectoryNode::DirectoryNode(const FileName &folderPath): Node(DirectoryNodeType,folderPath)
{
_fileWatcher.addPath(folderPath.toString());
connect(&_fileWatcher,SIGNAL(directoryChanged(QString)), this, SLOT(refresh()));
_dirObject = QDir(folderPath.toString());
setText(_dirObject.dirName());
setIcon(QIcon(":/drawable/nodes/folder"));
refresh();
}
示例4: makeCommand
QString AndroidToolChain::makeCommand(const Environment &env) const
{
QStringList extraDirectories = AndroidConfigurations::currentConfig().makeExtraSearchDirectories();
if (HostOsInfo::isWindowsHost()) {
FileName tmp = env.searchInPath(QLatin1String("ma-make.exe"), extraDirectories);
if (!tmp.isEmpty())
return QString();
tmp = env.searchInPath(QLatin1String("mingw32-make"), extraDirectories);
return tmp.isEmpty() ? QLatin1String("mingw32-make") : tmp.toString();
}
QString make = QLatin1String("make");
FileName tmp = env.searchInPath(make, extraDirectories);
return tmp.isEmpty() ? make : tmp.toString();
}
示例5: write
/**
* Writes a list of files to a file.
*
* @param list The name of the file to create. The method will overwrite any
* existing files.
*
* @throws Isis::iException::Io File could not be created.
*/
void FileList::write(FileName outputFileList) {
// Open the file
ofstream ostm;
ostm.open(outputFileList.toString().toAscii().data(), std::ios::out);
if (!ostm) {
QString message = Message::FileOpen(outputFileList.toString());
throw IException(IException::Io, message, _FILEINFO_);
}
// Internalize
write(ostm);
// Close the file
ostm.close();
}
示例6: init
bool QMakeStep::init()
{
QmakeBuildConfiguration *qt4bc = qmakeBuildConfiguration();
const QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitInformation::qtVersion(target()->kit());
if (!qtVersion)
return false;
QString args = allArguments();
QString workingDirectory;
if (qt4bc->subNodeBuild())
workingDirectory = qt4bc->subNodeBuild()->buildDir();
else
workingDirectory = qt4bc->buildDirectory().toString();
FileName program = qtVersion->qmakeCommand();
QString makefile = workingDirectory;
if (qt4bc->subNodeBuild()) {
if (!qt4bc->subNodeBuild()->makefile().isEmpty())
makefile.append(qt4bc->subNodeBuild()->makefile());
else
makefile.append(QLatin1String("/Makefile"));
} else if (!qt4bc->makefile().isEmpty()) {
makefile.append(QLatin1Char('/'));
makefile.append(qt4bc->makefile());
} else {
makefile.append(QLatin1String("/Makefile"));
}
// Check whether we need to run qmake
bool makefileOutDated = (qt4bc->compareToImportFrom(makefile) != QmakeBuildConfiguration::MakefileMatches);
if (m_forced || makefileOutDated)
m_needToRunQMake = true;
m_forced = false;
ProcessParameters *pp = processParameters();
pp->setMacroExpander(qt4bc->macroExpander());
pp->setWorkingDirectory(workingDirectory);
pp->setCommand(program.toString());
pp->setArguments(args);
pp->setEnvironment(qt4bc->environment());
pp->resolveAll();
setOutputParser(new QMakeParser);
QmakeProFileNode *node = static_cast<QmakeProject *>(qt4bc->target()->project())->rootQmakeProjectNode();
if (qt4bc->subNodeBuild())
node = qt4bc->subNodeBuild();
QString proFile = node->path();
m_tasks = qtVersion->reportIssues(proFile, workingDirectory);
qSort(m_tasks);
m_scriptTemplate = node->projectType() == ScriptTemplate;
return AbstractProcessStep::init();
}
示例7: updateExternalFileWarning
void ProjectTree::updateExternalFileWarning()
{
Core::IDocument *document = qobject_cast<Core::IDocument *>(sender());
if (!document || document->filePath().isEmpty())
return;
Core::InfoBar *infoBar = document->infoBar();
Core::Id externalFileId(EXTERNAL_FILE_WARNING);
if (!document->isModified()) {
infoBar->removeInfo(externalFileId);
return;
}
if (!infoBar->canInfoBeAdded(externalFileId))
return;
const FileName fileName = document->filePath();
const QList<Project *> projects = SessionManager::projects();
if (projects.isEmpty())
return;
foreach (Project *project, projects) {
FileName projectDir = project->projectDirectory();
if (projectDir.isEmpty())
continue;
if (fileName.isChildOf(projectDir))
return;
// External file. Test if it under the same VCS
QString topLevel;
if (Core::VcsManager::findVersionControlForDirectory(projectDir.toString(), &topLevel)
&& fileName.isChildOf(FileName::fromString(topLevel))) {
return;
}
}
示例8: addToEnvironment
void GccToolChain::addToEnvironment(Environment &env) const
{
if (!m_compilerCommand.isEmpty()) {
FileName path = m_compilerCommand.parentDir();
env.prependOrSetPath(path.toString());
}
}
示例9: triggerQtVersionRestore
void QtVersionManager::triggerQtVersionRestore()
{
disconnect(ProjectExplorer::ToolChainManager::instance(), SIGNAL(toolChainsLoaded()),
this, SLOT(triggerQtVersionRestore()));
bool success = restoreQtVersions();
m_instance->updateFromInstaller(false);
if (!success) {
// We did neither restore our settings or upgraded
// in that case figure out if there's a qt in path
// and add it to the Qt versions
findSystemQt();
}
emit m_instance->qtVersionsLoaded();
emit m_instance->qtVersionsChanged(m_versions.keys(), QList<int>(), QList<int>());
saveQtVersions();
const FileName configFileName = globalSettingsFileName();
if (configFileName.toFileInfo().exists()) {
m_configFileWatcher = new FileSystemWatcher(m_instance);
connect(m_configFileWatcher, SIGNAL(fileChanged(QString)),
m_fileWatcherTimer, SLOT(start()));
m_configFileWatcher->addFile(configFileName.toString(),
FileSystemWatcher::WatchModifiedDate);
} // exists
}
示例10: environmentFile
FileName PokySDKKitInformation::environmentFile(const Kit *kit)
{
FileName envFile;
ToolChain *tc = ToolChainKitInformation::toolChain(kit);
if (tc)
{
envFile = findEnvFromCompiler(tc->compilerCommand());
if (QFile::exists(envFile.toString()))
return envFile;
}
envFile = findEnvFromSysroot(SysRootKitInformation::sysRoot(kit));
if (QFile::exists(envFile.toString()))
return envFile;
else
return FileName();
}
示例11: makeCommand
QString AndroidToolChain::makeCommand(const Environment &env) const
{
FileName makePath = AndroidConfigurations::currentConfig().makePath();
if (makePath.exists())
return makePath.toString();
const Utils::FileNameList extraDirectories
= Utils::transform(AndroidConfigurations::currentConfig().makeExtraSearchDirectories(),
[](const QString &s) { return Utils::FileName::fromString(s); });
if (HostOsInfo::isWindowsHost()) {
makePath = env.searchInPath("ma-make.exe", extraDirectories);
if (!makePath.isEmpty())
return makePath.toString();
makePath = env.searchInPath("mingw32-make", extraDirectories);
return makePath.isEmpty() ? QLatin1String("mingw32-make") : makePath.toString();
}
makePath = env.searchInPath("make", extraDirectories);
return makePath.isEmpty() ? "make" : makePath.toString();
}
示例12: coreFileChanged
void AttachCoreDialog::coreFileChanged(const QString &core)
{
Kit *k = d->kitChooser->currentKit();
QTC_ASSERT(k, return);
FileName cmd = DebuggerKitInformation::debuggerCommand(k);
bool isCore = false;
QString exe = readExecutableNameFromCore(cmd.toString(), core, &isCore);
d->localExecFileName->setFileName(FileName::fromString(exe));
changed();
}
示例13: findEnvFromSysroot
FileName PokySDKKitInformation::findEnvFromSysroot(const FileName &sysRoot)
{
const QString sysRootStr = sysRoot.toString();
int idx = sysRootStr.indexOf(QLatin1String("/sysroots/"));
if (idx < 0)
return FileName();
QString envFile = QString(QLatin1String("%1/environment-setup-%2"))
.arg(sysRootStr.left(idx), sysRoot.toFileInfo().fileName());
return FileName::fromString(envFile);
}
示例14: runtime_error
std::unique_ptr<std::iostream> SerialProvider::open(const FileName & filename){
const PortInfo info = getPortInfo(filename);
std::unique_ptr<serial::Serial> port( new serial::Serial( info.internalPortName,info.baudRate,
serial::Timeout(),info.bytesize,info.parity,
info.stopbits,info.flowcontrol ));
if(!port->isOpen())
throw std::runtime_error("SerialProvider::open: Could not open port: "+filename.toString());
return std::unique_ptr<std::iostream> (new SerialIOStream(std::move(port)));
}
示例15: addToEnvironment
void PokySDKKitInformation::addToEnvironment(const Kit *kit, Environment &env) const
{
FileName pokyEnvFile = environmentFile(kit);
if (pokyEnvFile.isEmpty())
return;
PokyRunner runner(pokyEnvFile.toString());
QProcessEnvironment pokyEnv = runner.processEnvironment();
foreach (QString key, pokyEnv.keys())
env.set(key, pokyEnv.value(key));
}