本文整理汇总了C++中FileName::exists方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::exists方法的具体用法?C++ FileName::exists怎么用?C++ FileName::exists使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::exists方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initialiseParams
bool GuiLog::initialiseParams(string const & data)
{
istringstream is(data);
Lexer lex;
lex.setStream(is);
string logtype, logfile;
lex >> logtype;
if (lex) {
lex.next(true);
logfile = lex.getString();
}
if (!lex)
// Parsing of the data failed.
return false;
logTypeCO->setEnabled(logtype == "latex");
logTypeCO->clear();
FileName log(logfile);
if (logtype == "latex") {
type_ = LatexLog;
logTypeCO->addItem(qt_("LaTeX"), toqstr(logtype));
FileName tmp = log;
tmp.changeExtension("blg");
if (tmp.exists())
logTypeCO->addItem(qt_("BibTeX"), QString("bibtex"));
tmp.changeExtension("ilg");
if (tmp.exists())
logTypeCO->addItem(qt_("Index"), QString("index"));
// FIXME: not sure "literate" still works.
} else if (logtype == "literate") {
type_ = LiterateLog;
logTypeCO->addItem(qt_("Literate"), toqstr(logtype));
} else if (logtype == "lyx2lyx") {
type_ = Lyx2lyxLog;
logTypeCO->addItem(qt_("LyX2LyX"), toqstr(logtype));
} else if (logtype == "vc") {
type_ = VCLog;
logTypeCO->addItem(qt_("Version Control"), toqstr(logtype));
} else
return false;
logfile_ = log;
updateContents();
return true;
}
示例2: file_not_found_hook
bool LyXVC::file_not_found_hook(FileName const & fn)
{
// Check if file is under RCS.
// This happens if we are trying to load non existent
// file on disk, but existent in ,v version.
bool foundRCS = !RCS::findFile(fn).empty();
bool foundCVS = foundRCS ? false : !CVS::findFile(fn).empty();
bool foundSVN = (foundRCS || foundCVS) ? false : !SVN::findFile(fn).empty();
bool foundGIT = (foundRCS || foundCVS || foundSVN) ? false : !GIT::findFile(fn).empty();
if (foundRCS || foundCVS || foundSVN || foundGIT) {
docstring const file = makeDisplayPath(fn.absFileName(), 20);
docstring const text =
bformat(_("Do you want to retrieve the document"
" %1$s from version control?"), file);
int const ret = Alert::prompt(_("Retrieve from version control?"),
text, 0, 1, _("&Retrieve"), _("&Cancel"));
if (ret == 0) {
// Since the retrieve commands are implemented using
// more general update commands we need to ensure that
// we do not change an existing file by accident.
if (fn.exists())
return false;
if (foundRCS)
return RCS::retrieve(fn);
else if (foundCVS)
return CVS::retrieve(fn);
else if (foundSVN)
return SVN::retrieve(fn);
else
return GIT::retrieve(fn);
}
}
return false;
}
示例3: 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.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
}
示例4: takeParsedConfiguration
CMakeConfig TeaLeafReader::takeParsedConfiguration()
{
FileName cacheFile = m_parameters.workDirectory;
cacheFile.appendPath(QLatin1String("CMakeCache.txt"));
if (!cacheFile.exists())
return { };
QString errorMessage;
CMakeConfig result = BuildDirManager::parseCMakeConfiguration(cacheFile, &errorMessage);
if (!errorMessage.isEmpty()) {
emit errorOccured(errorMessage);
return { };
}
const FileName sourceOfBuildDir
= FileName::fromUtf8(CMakeConfigItem::valueOf("CMAKE_HOME_DIRECTORY", result));
const FileName canonicalSourceOfBuildDir = FileUtils::canonicalPath(sourceOfBuildDir);
const FileName canonicalSourceDirectory = FileUtils::canonicalPath(m_parameters.sourceDirectory);
if (canonicalSourceOfBuildDir != canonicalSourceDirectory) { // Uses case-insensitive compare where appropriate
emit errorOccured(tr("The build directory is not for %1 but for %2")
.arg(canonicalSourceOfBuildDir.toUserOutput(),
canonicalSourceDirectory.toUserOutput()));
return { };
}
return result;
}
示例5: init
bool NimCompilerCleanStep::init()
{
FileName buildDir = buildConfiguration()->buildDirectory();
bool result = buildDir.exists();
if (result)
m_buildDir = buildDir;
return result;
}
示例6: checkOverwrite
/// Ask the user what to do if a file already exists
static int checkOverwrite(FileName const & filename)
{
if (!filename.exists())
return 1;
docstring text = bformat(_("The file %1$s already exists.\n\n"
"Do you want to overwrite that file?"),
makeDisplayPath(filename.absFileName()));
return Alert::prompt(_("Overwrite file?"),
text, 0, 3,
_("&Keep file"), _("&Overwrite"),
_("Overwrite &all"), _("&Cancel export"));
}
示例7: while
// Produce side info =====================================================
void ProgClassifyCL2DCore::produceSideInfo()
{
// Get maximum CL2D level
maxLevel=0;
FileName fnLevel;
do
fnLevel=formatString("%s/level_%02d/%s_classes.xmd",fnODir.c_str(),maxLevel++,fnRoot.c_str());
while (fnLevel.exists());
maxLevel-=2;
if (maxLevel==-1)
REPORT_ERROR(ERR_ARG_MISSING,"Cannot find any CL2D analysis in the directory given");
// Read all the blocks available in all MetaData
StringVector blocksAux;
CL2DBlock block;
for (int level=0; level<=maxLevel; level++)
{
fnLevel=formatString("%s/level_%02d/%s_classes.xmd",fnODir.c_str(),level,fnRoot.c_str());
getBlocksInMetaDataFile(fnLevel,blocksAux);
block.level=level;
block.fnLevel=fnLevel;
block.fnLevelCore=fnLevel.insertBeforeExtension("_core");
for (size_t i=0; i<blocksAux.size(); i++)
{
if (blocksAux[i].find("class")!=std::string::npos &&
blocksAux[i].find("images")!=std::string::npos)
{
block.block=blocksAux[i];
blocks.push_back(block);
}
}
}
// Create a task file distributor for all blocks
size_t Nblocks=blocks.size();
taskDistributor=new MpiTaskDistributor(Nblocks,1,node);
// Get image dimensions
if (Nblocks>0)
{
size_t Zdim, Ndim;
getImageSizeFromFilename(blocks[0].block+"@"+blocks[0].fnLevel,Xdim,Ydim,Zdim,Ndim);
}
}
示例8: 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();
}
示例9: getPastedGraphicsFileName
//.........这里部分代码省略.........
// select prefered type if AnyGraphicsType was passed
if (type == Clipboard::AnyGraphicsType)
type = types.front();
// which extension?
map<Clipboard::GraphicsType, string> extensions;
map<Clipboard::GraphicsType, docstring> typeNames;
extensions[Clipboard::EmfGraphicsType] = "emf";
extensions[Clipboard::WmfGraphicsType] = "wmf";
extensions[Clipboard::LinkBackGraphicsType] = "linkback";
extensions[Clipboard::PdfGraphicsType] = "pdf";
extensions[Clipboard::PngGraphicsType] = "png";
extensions[Clipboard::JpegGraphicsType] = "jpeg";
typeNames[Clipboard::EmfGraphicsType] = _("Enhanced Metafile");
typeNames[Clipboard::WmfGraphicsType] = _("Windows Metafile");
typeNames[Clipboard::LinkBackGraphicsType] = _("LinkBack PDF");
typeNames[Clipboard::PdfGraphicsType] = _("PDF");
typeNames[Clipboard::PngGraphicsType] = _("PNG");
typeNames[Clipboard::JpegGraphicsType] = _("JPEG");
// find unused filename with primary extension
string document_path = cur.buffer()->fileName().onlyPath().absFileName();
unsigned newfile_number = 0;
FileName filename;
do {
++newfile_number;
filename = FileName(addName(document_path,
to_utf8(_("pasted"))
+ convert<string>(newfile_number) + "."
+ extensions[type]));
} while (filename.isReadableFile());
while (true) {
// create file type filter, putting the prefered on to the front
QStringList filter;
for (size_t i = 0; i != types.size(); ++i) {
docstring s = bformat(_("%1$s Files"), typeNames[types[i]])
+ " (*." + from_ascii(extensions[types[i]]) + ")";
if (types[i] == type)
filter.prepend(toqstr(s));
else
filter.append(toqstr(s));
}
filter = fileFilters(filter.join(";;"));
// show save dialog for the graphic
FileDialog dlg(qt_("Choose a filename to save the pasted graphic as"));
FileDialog::Result result =
dlg.save(toqstr(filename.onlyPath().absFileName()), filter,
toqstr(filename.onlyFileName()));
if (result.first == FileDialog::Later)
return FileName();
string newFilename = fromqstr(result.second);
if (newFilename.empty()) {
cur.bv().message(_("Canceled."));
return FileName();
}
filename.set(newFilename);
// check the extension (the user could have changed it)
if (!suffixIs(ascii_lowercase(filename.absFileName()),
"." + extensions[type])) {
// the user changed the extension. Check if the type is available
size_t i;
for (i = 1; i != types.size(); ++i) {
if (suffixIs(ascii_lowercase(filename.absFileName()),
"." + extensions[types[i]])) {
type = types[i];
break;
}
}
// invalid extension found, or none at all. In the latter
// case set the default extensions.
if (i == types.size()
&& filename.onlyFileName().find('.') == string::npos) {
filename.changeExtension("." + extensions[type]);
}
}
// check whether the file exists and warn the user
if (!filename.exists())
break;
int ret = frontend::Alert::prompt(
_("Overwrite external file?"),
bformat(_("File %1$s already exists, do you want to overwrite it?"),
from_utf8(filename.absFileName())), 1, 1, _("&Overwrite"), _("&Cancel"));
if (ret == 0)
// overwrite, hence break the dialog loop
break;
// not overwrite, hence show the dialog again (i.e. loop)
}
return filename;
}
示例10: deleteFile
/* Delete file exists -------------------------------------------------- */
void FileName::deleteFile() const
{
FileName temp = this->removeFileFormat().removeAllPrefixes();
if (temp.exists())
unlink(temp.c_str());
}