21 QString QgsCreateDirectoryAlgorithm::name()
 const 
   23   return QStringLiteral( 
"createdirectory" );
 
   26 QgsProcessingAlgorithm::Flags QgsCreateDirectoryAlgorithm::flags()
 const 
   28   return FlagHideFromToolbox | FlagSkipGenericModelLogging;
 
   31 QString QgsCreateDirectoryAlgorithm::displayName()
 const 
   33   return QObject::tr( 
"Create directory" );
 
   36 QStringList QgsCreateDirectoryAlgorithm::tags()
 const 
   38   return QObject::tr( 
"new,make,folder" ).split( 
',' );
 
   41 QString QgsCreateDirectoryAlgorithm::group()
 const 
   43   return QObject::tr( 
"Modeler tools" );
 
   46 QString QgsCreateDirectoryAlgorithm::groupId()
 const 
   48   return QStringLiteral( 
"modelertools" );
 
   51 QString 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." );
 
   58 QString QgsCreateDirectoryAlgorithm::shortDescription()
 const 
   60   return QObject::tr( 
"Creates a new directory on a file system." );
 
   63 QgsCreateDirectoryAlgorithm *QgsCreateDirectoryAlgorithm::createInstance()
 const 
   65   return new QgsCreateDirectoryAlgorithm();
 
   68 void 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 );
 
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.