21QString QgsCreateDirectoryAlgorithm::name()
const
23 return QStringLiteral(
"createdirectory" );
31QString QgsCreateDirectoryAlgorithm::displayName()
const
33 return QObject::tr(
"Create directory" );
36QStringList QgsCreateDirectoryAlgorithm::tags()
const
38 return QObject::tr(
"new,make,folder" ).split(
',' );
41QString QgsCreateDirectoryAlgorithm::group()
const
43 return QObject::tr(
"Modeler tools" );
46QString QgsCreateDirectoryAlgorithm::groupId()
const
48 return QStringLiteral(
"modelertools" );
51QString QgsCreateDirectoryAlgorithm::shortHelpString()
const
53 return QObject::tr(
"This algorithm creates a new directory on a file system. Directories will be created recursively, creating all "
54 "required parent directories in order to construct the full specified directory path.\n\n"
55 "No errors will be raised if the directory already exists." );
58QString QgsCreateDirectoryAlgorithm::shortDescription()
const
60 return QObject::tr(
"Creates a new directory on a file system." );
63QgsCreateDirectoryAlgorithm *QgsCreateDirectoryAlgorithm::createInstance()
const
65 return new QgsCreateDirectoryAlgorithm();
68void QgsCreateDirectoryAlgorithm::initAlgorithm(
const QVariantMap & )
76 const QString path = parameterAsString( parameters, QStringLiteral(
"PATH" ), context );
78 if ( !path.isEmpty() )
80 if ( QFile::exists( path ) )
82 if ( !QFileInfo( path ).isDir() )
83 throw QgsProcessingException( QObject::tr(
"A file with the name %1 already exists -- cannot create a new directory here." ).arg( path ) );
85 feedback->
pushInfo( QObject::tr(
"The directory %1 already exists." ).arg( path ) );
89 if ( !QDir().mkpath( path ) )
91 throw QgsProcessingException( QObject::tr(
"Could not create directory %1. Please check that you have write permissions for the specified path." ).arg( path ) );
95 feedback->
pushInfo( QObject::tr(
"Created %1" ).arg( path ) );
100 results.insert( QStringLiteral(
"OUTPUT" ), path );
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
@ HideFromToolbox
Algorithm should be hidden from the toolbox.
@ SkipGenericModelLogging
When running as part of a model, the generic algorithm setup and results logging should be skipped.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A folder output for processing algorithms.
A map layer parameter for processing algorithms.