本文整理汇总了C++中QTemporaryDir::remove方法的典型用法代码示例。如果您正苦于以下问题:C++ QTemporaryDir::remove方法的具体用法?C++ QTemporaryDir::remove怎么用?C++ QTemporaryDir::remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTemporaryDir
的用法示例。
在下文中一共展示了QTemporaryDir::remove方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyBool_FromLong
static PyObject *meth_QTemporaryDir_remove(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QTemporaryDir *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QTemporaryDir, &sipCpp))
{
bool sipRes;
sipRes = sipCpp->remove();
return PyBool_FromLong(sipRes);
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QTemporaryDir, sipName_remove, doc_QTemporaryDir_remove);
return NULL;
}
示例2: testImageLocalDirectory
void DocumentTest::testImageLocalDirectory() {
Tellico::Config::setImageLocation(Tellico::Config::ImagesInLocalDir);
// the default collection will use a temporary directory as a local image dir
QVERIFY(!Tellico::ImageFactory::localDir().isEmpty());
QString tempDirName;
QTemporaryDir tempDir;
QVERIFY(tempDir.isValid());
tempDir.setAutoRemove(true);
tempDirName = tempDir.path();
QString fileName = tempDirName + "/with-image.tc";
QString imageDirName = tempDirName + "/with-image_files/";
// copy a collection file that includes an image into the temporary directory
QVERIFY(QFile::copy(QFINDTESTDATA("data/with-image.tc"), fileName));
Tellico::Data::Document* doc = Tellico::Data::Document::self();
QVERIFY(doc->openDocument(QUrl::fromLocalFile(fileName)));
QCOMPARE(Tellico::ImageFactory::localDir(), imageDirName);
Tellico::Data::CollPtr coll = doc->collection();
QVERIFY(coll);
QCOMPARE(coll->type(), Tellico::Data::Collection::Book);
QCOMPARE(coll->title(), QLatin1String("My Books"));
QCOMPARE(coll->entries().size(), 1);
Tellico::Data::EntryPtr e = coll->entries().at(0);
QVERIFY(e);
QCOMPARE(e->field(QLatin1String("cover")), QLatin1String("17b54b2a742c6d342a75f122d615a793.jpeg"));
// save the document, so the images get copied out of the .tc file into the local image directory
QVERIFY(doc->saveDocument(QUrl::fromLocalFile(fileName)));
// verify that backup file gets created
QVERIFY(QFile::exists(fileName + '~'));
// check that the local image directory is created with the image file inside
QDir imageDir(imageDirName);
QVERIFY(imageDir.exists());
QVERIFY(imageDir.exists(e->field(QLatin1String("cover"))));
// clear the internal image cache
Tellico::ImageFactory::clean(true);
// verify that the images are copied from the old directory when saving to a new file
QString fileName2 = tempDirName + "/with-image2.tc";
QString imageDirName2 = tempDirName + "/with-image2_files/";
QVERIFY(doc->saveDocument(QUrl::fromLocalFile(fileName2)));
QVERIFY(QFile::exists(fileName2));
QDir imageDir2(imageDirName2);
QVERIFY(imageDir2.exists());
QVERIFY(imageDir2.exists(e->field(QLatin1String("cover"))));
/*************************************************************************/
/* now also verify image directory when file name has multiple periods */
/* see https://bugs.kde.org/show_bug.cgi?id=348088 */
/* also have to check backwards compatibility with prior behavior */
/*************************************************************************/
QString fileName3 = tempDirName + "/with-image.1.tc";
QString imageDirName3 = tempDirName + "/with-image.1_files/";
// copy the collection file, which no longer contains the images inside
QVERIFY(QFile::copy(fileName, fileName3));
QVERIFY(doc->openDocument(QUrl::fromLocalFile(fileName3)));
QCOMPARE(Tellico::ImageFactory::localDir(), imageDirName3);
QDir imageDir3(imageDirName3);
// verify that the images can be loaded from the image directory that does NOT have multiple periods
// since that was the behavior prior to the bug being fixed
coll = doc->collection();
e = coll->entries().at(0);
// image should not be in the next image dir yet since we haven't saved
QVERIFY(!imageDir3.exists(e->field(QLatin1String("cover"))));
QVERIFY(!Tellico::ImageFactory::imageById(e->field("cover")).isNull());
// now remove the first image from the first image directory, save the document, and verify that
// the proper image exists and is written
QVERIFY(imageDir.remove(e->field("cover")));
QVERIFY(!imageDir.exists(e->field(QLatin1String("cover"))));
QVERIFY(doc->saveDocument(QUrl::fromLocalFile(fileName3)));
// now the file should exist in the proper location
QVERIFY(imageDir3.exists(e->field(QLatin1String("cover"))));
// clear the cache
Tellico::ImageFactory::clean(true);
QVERIFY(!Tellico::ImageFactory::imageById(e->field("cover")).isNull());
// sanity check, the directory should not exists after QTemporaryDir destruction
tempDir.remove();
QVERIFY(!QDir(tempDirName).exists());
}
示例3: createProject
QString AppWizardPlugin::createProject(const ApplicationInfo& info)
{
QFileInfo templateInfo(info.appTemplate);
if (!templateInfo.exists()) {
qWarning() << "Project app template does not exist:" << info.appTemplate;
return QString();
}
QString templateName = templateInfo.baseName();
QString templateArchive;
const QStringList filters = {templateName + QStringLiteral(".*")};
const QStringList matchesPaths = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, QStringLiteral("kdevappwizard/templates/"), QStandardPaths::LocateDirectory);
foreach(const QString& matchesPath, matchesPaths) {
const QStringList files = QDir(matchesPath).entryList(filters);
if(!files.isEmpty()) {
templateArchive = matchesPath + files.first();
}
}
if(templateArchive.isEmpty()) {
qWarning() << "Template name does not exist in the template list";
return QString();
}
QUrl dest = info.location;
//prepare variable substitution hash
m_variables.clear();
m_variables[QStringLiteral("APPNAME")] = info.name;
m_variables[QStringLiteral("APPNAMEUC")] = info.name.toUpper();
m_variables[QStringLiteral("APPNAMELC")] = info.name.toLower();
m_variables[QStringLiteral("APPNAMEID")] = generateIdentifier(info.name);
m_variables[QStringLiteral("PROJECTDIR")] = dest.toLocalFile();
// backwards compatibility
m_variables[QStringLiteral("dest")] = m_variables[QStringLiteral("PROJECTDIR")];
m_variables[QStringLiteral("PROJECTDIRNAME")] = dest.fileName();
m_variables[QStringLiteral("VERSIONCONTROLPLUGIN")] = info.vcsPluginName;
KArchive* arch = nullptr;
if( templateArchive.endsWith(QLatin1String(".zip")) )
{
arch = new KZip(templateArchive);
}
else
{
arch = new KTar(templateArchive, QStringLiteral("application/x-bzip"));
}
if (arch->open(QIODevice::ReadOnly))
{
QTemporaryDir tmpdir;
QString unpackDir = tmpdir.path(); //the default value for all Centralized VCS
IPlugin* plugin = core()->pluginController()->loadPlugin( info.vcsPluginName );
if( info.vcsPluginName.isEmpty() || ( plugin && plugin->extension<KDevelop::IDistributedVersionControl>() ) )
{
if( !QFileInfo::exists( dest.toLocalFile() ) )
{
QDir::root().mkpath( dest.toLocalFile() );
}
unpackDir = dest.toLocalFile(); //in DVCS we unpack template directly to the project's directory
}
else
{
QUrl url = KIO::upUrl(dest);
if(!QFileInfo::exists(url.toLocalFile())) {
QDir::root().mkpath(url.toLocalFile());
}
}
if ( !unpackArchive( arch->directory(), unpackDir ) )
{
QString errorMsg = i18n("Could not create new project");
vcsError(errorMsg, tmpdir, QUrl::fromLocalFile(unpackDir));
return QString();
}
if( !info.vcsPluginName.isEmpty() )
{
if (!plugin)
{
// Red Alert, serious program corruption.
// This should never happen, the vcs dialog presented a list of vcs
// systems and now the chosen system doesn't exist anymore??
tmpdir.remove();
return QString();
}
IDistributedVersionControl* dvcs = toDVCS(plugin);
ICentralizedVersionControl* cvcs = toCVCS(plugin);
bool success = false;
if (dvcs)
{
success = initializeDVCS(dvcs, info, tmpdir);
}
else if (cvcs)
{
success = initializeCVCS(cvcs, info, tmpdir);
}
else
{
if (KMessageBox::Continue ==
//.........这里部分代码省略.........