forked from qt-creator/qt-creator
Use new FilePath::setPermissions in a few cases
Change-Id: Ic7122c86c273a87134ea8cd1a00b1bbdf5035971 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -329,8 +329,7 @@ QString FileUtils::qmakeFriendlyName(const QString &name)
|
||||
|
||||
bool FileUtils::makeWritable(const FilePath &path)
|
||||
{
|
||||
const QString filePath = path.toString();
|
||||
return QFile::setPermissions(filePath, QFile::permissions(filePath) | QFile::WriteUser);
|
||||
return path.setPermissions(path.permissions() | QFile::WriteUser);
|
||||
}
|
||||
|
||||
// makes sure that capitalization of directories is canonical on Windows and OS X.
|
||||
|
@@ -185,7 +185,7 @@ void FilePropertiesDialog::setPermission(QFile::Permissions newPermissions, bool
|
||||
else
|
||||
permissions &= ~newPermissions;
|
||||
|
||||
if (!QFile::setPermissions(m_filePath.toString(), permissions))
|
||||
if (!m_filePath.setPermissions(permissions))
|
||||
qWarning() << "Cannot change permissions for file" << m_filePath;
|
||||
});
|
||||
|
||||
|
@@ -52,17 +52,20 @@
|
||||
using namespace ProjectExplorer;
|
||||
using namespace Utils;
|
||||
|
||||
namespace CppTools {
|
||||
namespace Tests {
|
||||
|
||||
static bool closeEditorsWithoutGarbageCollectorInvocation(const QList<Core::IEditor *> &editors)
|
||||
{
|
||||
CppTools::CppModelManager::instance()->enableGarbageCollector(false);
|
||||
CppModelManager::instance()->enableGarbageCollector(false);
|
||||
const bool closeEditorsSucceeded = Core::EditorManager::closeEditors(editors, false);
|
||||
CppTools::CppModelManager::instance()->enableGarbageCollector(true);
|
||||
CppModelManager::instance()->enableGarbageCollector(true);
|
||||
return closeEditorsSucceeded;
|
||||
}
|
||||
|
||||
static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QSet<QString> &filePaths)
|
||||
{
|
||||
foreach (const QString &filePath, filePaths) {
|
||||
for (const QString &filePath : filePaths) {
|
||||
if (!snapshot.contains(filePath)) {
|
||||
qWarning() << "Missing file in snapshot:" << qPrintable(filePath);
|
||||
return false;
|
||||
@@ -71,9 +74,6 @@ static bool snapshotContains(const CPlusPlus::Snapshot &snapshot, const QSet<QSt
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace CppTools {
|
||||
namespace Tests {
|
||||
|
||||
TestDocument::TestDocument(const QByteArray &fileName, const QByteArray &source, char cursorMarker)
|
||||
: m_fileName(QString::fromUtf8(fileName))
|
||||
, m_source(QString::fromUtf8(source))
|
||||
@@ -214,7 +214,7 @@ QList<CPlusPlus::Document::Ptr> TestCase::waitForFilesInGlobalSnapshot(const QSt
|
||||
t.start();
|
||||
|
||||
QList<CPlusPlus::Document::Ptr> result;
|
||||
foreach (const QString &filePath, filePaths) {
|
||||
for (const QString &filePath : filePaths) {
|
||||
forever {
|
||||
if (CPlusPlus::Document::Ptr document = globalSnapshot().document(filePath)) {
|
||||
result.append(document);
|
||||
@@ -333,8 +333,7 @@ static bool copyRecursively(const QString &sourceDirPath,
|
||||
|
||||
// Copied files from Qt resources are read-only. Make them writable
|
||||
// so that their parent directory can be removed without warnings.
|
||||
QFile file(targetPath.toString());
|
||||
return file.setPermissions(file.permissions() | QFile::WriteUser);
|
||||
return targetPath.setPermissions(targetPath.permissions() | QFile::WriteUser);
|
||||
};
|
||||
|
||||
return Utils::FileUtils::copyRecursively(Utils::FilePath::fromString(sourceDirPath),
|
||||
|
@@ -123,8 +123,7 @@ bool Operation::save(const QVariantMap &map, const QString &file) const
|
||||
<< "." << std::endl;
|
||||
return false;
|
||||
}
|
||||
if (!QFile::setPermissions(path.toString(),
|
||||
QFile::ReadOwner | QFile::WriteOwner
|
||||
if (!path.setPermissions(QFile::ReadOwner | QFile::WriteOwner
|
||||
| QFile::ReadGroup | QFile::ReadOther)) {
|
||||
std::cerr << "Error: Could not set permissions for " << qPrintable(path.toString())
|
||||
<< "." << std::endl;
|
||||
|
Reference in New Issue
Block a user