Esempio n. 1
0
/* 'mkdir' attempts to create a maildir directory at 'path:'; sends an
 * (:info mkdir ...) message when it succeeds */
static MuError
cmd_mkdir (ServerContext *ctx, GSList *args, GError **err)
{
	const char *path;

	GET_STRING_OR_ERROR_RETURN (args, "path", &path, err);

	if (!mu_maildir_mkdir (path, 0755, FALSE, err))
		print_and_clear_g_error (err);
	else
		print_expr ("(:info mkdir :message \"%s has been created\")",
			    path);

	return MU_OK;
}
Esempio n. 2
0
static gboolean
prepare_links (MuConfig *opts, GError **err)
{
	/* note, mu_maildir_mkdir simply ignores whatever part of the
	 * mail dir already exists */

	if (!mu_maildir_mkdir (opts->linksdir, 0700, TRUE, err)) {
		mu_util_g_set_error (err, MU_ERROR_FILE_CANNOT_MKDIR,
				     "error creating %s", opts->linksdir);
		return FALSE;
	}

	if (opts->clearlinks &&
	    !mu_maildir_clear_links (opts->linksdir, err)) {
			mu_util_g_set_error (err, MU_ERROR_FILE,
					     "error clearing links under %s",
					     opts->linksdir);
			return FALSE;
	}

	return TRUE;
}
Esempio n. 3
0
MuError
mu_cmd_mkdir (MuConfig *opts, GError **err)
{
	int i;

	g_return_val_if_fail (opts, MU_ERROR_INTERNAL);
	g_return_val_if_fail (opts->cmd == MU_CONFIG_CMD_MKDIR,
			      MU_ERROR_INTERNAL);

	if (!opts->params[1]) {
		mu_util_g_set_error (err, MU_ERROR_IN_PARAMETERS,
				     "missing directory parameter");
		return MU_ERROR_IN_PARAMETERS;
	}

	for (i = 1; opts->params[i]; ++i)
		if (!mu_maildir_mkdir (opts->params[i], opts->dirmode,
				       FALSE, err))
			return err && *err ? (*err)->code :
				MU_ERROR_FILE_CANNOT_MKDIR;
	return MU_OK;
}