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
57 return QObject::tr(
"This algorithm creates a new directory on a file system. Directories will be created recursively, creating all "
58 "required parent directories in order to construct the full specified directory path.\n\n"
59 "No errors will be raised if the directory already exists." );
62QString QgsCreateDirectoryAlgorithm::shortDescription()
const
64 return QObject::tr(
"Creates a new directory on a file system." );
67QgsCreateDirectoryAlgorithm *QgsCreateDirectoryAlgorithm::createInstance()
const
69 return new QgsCreateDirectoryAlgorithm();
72void QgsCreateDirectoryAlgorithm::initAlgorithm(
const QVariantMap & )
80 const QString path = parameterAsString( parameters, u
"PATH"_s, context );
82 if ( !path.isEmpty() )
84 if ( QFile::exists( path ) )
86 if ( !QFileInfo( path ).isDir() )
87 throw QgsProcessingException( QObject::tr(
"A file with the name %1 already exists -- cannot create a new directory here." ).arg( path ) );
89 feedback->
pushInfo( QObject::tr(
"The directory %1 already exists." ).arg( path ) );
93 if ( !QDir().mkpath( path ) )
95 throw QgsProcessingException( QObject::tr(
"Could not create directory %1. Please check that you have write permissions for the specified path." ).arg( path ) );
99 feedback->
pushInfo( QObject::tr(
"Created %1" ).arg( path ) );
104 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.