21using namespace Qt::StringLiterals;
25QString QgsCreateDirectoryAlgorithm::name()
const
27 return u
"createdirectory"_s;
35QString QgsCreateDirectoryAlgorithm::displayName()
const
37 return QObject::tr(
"Create directory" );
40QStringList QgsCreateDirectoryAlgorithm::tags()
const
42 return QObject::tr(
"new,make,folder" ).split(
',' );
45QString QgsCreateDirectoryAlgorithm::group()
const
47 return QObject::tr(
"Modeler tools" );
50QString QgsCreateDirectoryAlgorithm::groupId()
const
52 return u
"modelertools"_s;
55QString QgsCreateDirectoryAlgorithm::shortHelpString()
const
58 "This algorithm creates a new directory on a file system. Directories will be created recursively, creating all "
59 "required parent directories in order to construct the full specified directory path.\n\n"
60 "No errors will be raised if the directory already exists."
64QString QgsCreateDirectoryAlgorithm::shortDescription()
const
66 return QObject::tr(
"Creates a new directory on a file system." );
69QgsCreateDirectoryAlgorithm *QgsCreateDirectoryAlgorithm::createInstance()
const
71 return new QgsCreateDirectoryAlgorithm();
74void QgsCreateDirectoryAlgorithm::initAlgorithm(
const QVariantMap & )
82 const QString path = parameterAsString( parameters, u
"PATH"_s, context );
84 if ( !path.isEmpty() )
86 if ( QFile::exists( path ) )
88 if ( !QFileInfo( path ).isDir() )
89 throw QgsProcessingException( QObject::tr(
"A file with the name %1 already exists -- cannot create a new directory here." ).arg( path ) );
91 feedback->
pushInfo( QObject::tr(
"The directory %1 already exists." ).arg( path ) );
95 if ( !QDir().mkpath( path ) )
97 throw QgsProcessingException( QObject::tr(
"Could not create directory %1. Please check that you have write permissions for the specified path." ).arg( path ) );
101 feedback->
pushInfo( QObject::tr(
"Created %1" ).arg( path ) );
106 results.insert( u
"OUTPUT"_s, 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.