mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Check if directory is readable before creating a script collection item
p4#: 21362
This commit is contained in:
parent
d825b0654c
commit
b20be8ad25
@ -110,7 +110,7 @@ void RimProject::setUserScriptPath(const QString& scriptDirectory)
|
||||
|
||||
|
||||
QDir dir(scriptDirectory);
|
||||
if (!scriptDirectory.isEmpty() && dir.exists())
|
||||
if (!scriptDirectory.isEmpty() && dir.exists() && dir.isReadable())
|
||||
{
|
||||
RimScriptCollection* sharedScriptLocation = new RimScriptCollection;
|
||||
sharedScriptLocation->directory = scriptDirectory;
|
||||
|
@ -67,6 +67,12 @@ void RimScriptCollection::readContentFromDisc()
|
||||
return;
|
||||
}
|
||||
|
||||
QDir myDir(this->directory());
|
||||
if (!myDir.isReadable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Build a list of all scripts in the specified directory
|
||||
{
|
||||
QString filter = "*.m";
|
||||
@ -93,7 +99,7 @@ void RimScriptCollection::readContentFromDisc()
|
||||
// Add subfolders
|
||||
{
|
||||
QDir dir(directory);
|
||||
QFileInfoList fileInfoList = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot);
|
||||
QFileInfoList fileInfoList = dir.entryInfoList(QDir::AllDirs | QDir::NoDotAndDotDot | QDir::Readable);
|
||||
subDirectories.deleteAllChildObjects();
|
||||
|
||||
QStringList retFileNames;
|
||||
@ -120,12 +126,19 @@ void RimScriptCollection::pathsAndSubPaths(QStringList& pathList)
|
||||
{
|
||||
if (!this->directory().isEmpty())
|
||||
{
|
||||
pathList.append(this->directory());
|
||||
QDir myDir(this->directory());
|
||||
if (myDir.isReadable())
|
||||
{
|
||||
pathList.append(this->directory());
|
||||
}
|
||||
}
|
||||
|
||||
for (size_t i= 0; i < this->subDirectories.size(); ++i)
|
||||
{
|
||||
if (this->subDirectories[i]) this->subDirectories[i]->pathsAndSubPaths(pathList);
|
||||
if (this->subDirectories[i])
|
||||
{
|
||||
this->subDirectories[i]->pathsAndSubPaths(pathList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user