Create archive subfolder if it doesn't yet exist
977627
private function subfolder_worker($folder)
    {
        $storage   = rcmail::get_instance()->get_storage();
        $delimiter = $storage->get_hierarchy_delimiter();

        if ($this->folders === null) {
            $this->folders = $storage->list_folders('', $archive_folder . '*', 'mail', null, true);
        }

        if (!in_array($folder, $this->folders)) {
            $path = explode($delimiter, $folder);

            // we'll create all folders in the path
            for ($i=0; $i<count($path); $i++) {
                $_folder = implode($delimiter, array_slice($path, 0, $i+1));
                if (!in_array($_folder, $this->folders)) {
                    if ($storage->create_folder($_folder, true)) {
                        $this->result['reload'] = true;
                        $this->folders[] = $_folder;
                    }
                }
            }
        }
    }
175202
function createTemporaryStorageFolder() {
  fs.mkdir(imageDir, '0775', function(err) {
    if (err && err.code !== 'EEXIST') {
      console.log(err);
      throw new Error(err);
    }
  });
}
499885
def check_archive_filelist (filenames):
    """"""
    if not filenames:
        raise PatoolError("cannot create archive with empty filelist")
    for filename in filenames:
        check_existing_filename(filename, onlyfiles=False)
535084
def ensure_dirs(filename):
    """"""
    dirname = os.path.dirname(filename)
    if dirname and not os.path.exists(dirname):
        os.makedirs(dirname)
1353049
function _ensureExists(dir, callback) {
    dir = path.resolve(dir); // make full path
    
    path.exists(dir, function(exists) {
        if (!exists) {
            // ensure that the parent dir exists
            _ensureExists(path.dirname(dir), function(err) {
                if (err) {
                    callback(err);
                    return;
                }
                
                // make the dir
                log.log('Creating ' + dir);
                fs.mkdir(dir, function(err) {
                    if (err) {
                        callback(err);
                        return;
                    }
                    
                    callback(null);
                });
            });
        }
        else {
            callback(null);
        }
    });
}
1328267
void startArchiving() {
		if (isArchivingDisabled()) {
			return;
		}

		String archiveName = configuration.get(JFunkConstants.ARCHIVE_FILE);
		if (StringUtils.isBlank(archiveName)) {
			archiveName = String.format(DIR_PATTERN, moduleMetaData.getModuleName(), Thread.currentThread().getName(),
					FORMAT.format(moduleMetaData.getStartDate()));
		}

		moduleArchiveDir = new File(archiveDir, archiveName);
		if (moduleArchiveDir.exists()) {
			log.warn("Archive directory already exists: {}", moduleArchiveDir);
		} else {
			moduleArchiveDir.mkdirs();
		}

		addModuleAppender();
		log.info("Started archiving: (module={}, moduleArchiveDir={})", moduleMetaData.getModuleName(), moduleArchiveDir);
	}
1226919
def archive_pathname(file_pathname)
      path = Pathname.new(archive_directory)
      path = file_pathname.dirname.join(archive_directory) if path.relative?

      begin
        path.mkpath unless path.exist?
      rescue Errno::ENOENT => exc
        raise(Errno::ENOENT, "DirmonJob failed to create archive directory: #{path}, #{exc.message}")
      end
      path.realpath
    end
942281
def create_new_folder(self, current_path, title, subtitle, is_package):
        """"""
        if current_path is None:
            current_path = ''
        if osp.isfile(current_path):
            current_path = osp.dirname(current_path)
        name, valid = QInputDialog.getText(self, title, subtitle,
                                           QLineEdit.Normal, "")
        if valid:
            dirname = osp.join(current_path, to_text_string(name))
            try:
                os.mkdir(dirname)
            except EnvironmentError as error:
                QMessageBox.critical(self, title,
                                     _("<b>Unable "
                                       "to create folder <i>%s</i></b>"
                                       "<br><br>Error message:<br>%s"
                                       ) % (dirname, to_text_string(error)))
            finally:
                if is_package:
                    fname = osp.join(dirname, '__init__.py')
                    try:
                        with open(fname, 'wb') as f:
                            f.write(to_binary_string('#'))
                        return dirname
                    except EnvironmentError as error:
                        QMessageBox.critical(self, title,
                                             _("<b>Unable "
                                               "to create file <i>%s</i></b>"
                                               "<br><br>Error message:<br>%s"
                                               ) % (fname,
                                                    to_text_string(error)))
317354
def ensure_dir_does_not_exist(*args):
    """"""
    path = os.path.join(*args)
    if os.path.isdir(path):
        shutil.rmtree(path)
439464
def _SConstruct_exists(dirname='', repositories=[], filelist=None):
    
    if not filelist:
        filelist = ['SConstruct', 'Sconstruct', 'sconstruct']
    for file in filelist:
        sfile = os.path.join(dirname, file)
        if os.path.isfile(sfile):
            return sfile
        if not os.path.isabs(sfile):
            for rep in repositories:
                if os.path.isfile(os.path.join(rep, sfile)):
                    return sfile
    return None
573988
def ensure_dir_exists(verify_dir):
    """"""
    if not os.path.exists(verify_dir):
        # Doesn't exist create dir
        os.makedirs(verify_dir)
    else:
        # Exists
        if not os.path.isdir(verify_dir):
            # Not a dir, raise an exception
            raise ValueError("{} is not a directory".format(verify_dir))
429173
def ensure_dir_exists(dir)
      unless Dir.exist?(dir)
        begin
          Dir.mkdir(dir)
        rescue IOError => e
          PEROBS.log.fatal "Cannote create DB directory '#{dir}': #{e.message}"
        end
      end
    end
711311
def repack_archive (archive, archive_new, verbosity=0, interactive=True):
    """"""
    util.check_existing_filename(archive)
    util.check_new_filename(archive_new)
    if verbosity >= 0:
        util.log_info("Repacking %s to %s ..." % (archive, archive_new))
    res = _repack_archive(archive, archive_new, verbosity=verbosity, interactive=interactive)
    if verbosity >= 0:
        util.log_info("... repacking successful.")
    return res
1347215
def ensure_parent_dir_exists(file_path):
    """"""
    parent = os.path.dirname(file_path)
    if parent:
        os.makedirs(parent, exist_ok=True)
1316270
def makedirs(name, mode=0o777, exist_ok=False):
    

    if os.path.exists(name):
        if not exist_ok:
            raise FileExistsError("File exists: " + name)
    else:
        os.makedirs(name, mode)
1064959
def _ensure_directory_exists(self, directory):
        """"""
        if not os.path.lexists(directory):
            os.makedirs(directory)
        return directory
1052836
def on_created(self, event, dry_run=False, remove_uploaded=True):
        ' '
        super(ArchiveEventHandler, self).on_created(event)
        log.info("created: %s", event)