aboutsummaryrefslogtreecommitdiffstats
path: root/camel/providers/local/camel-local-store.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2004-02-14 03:45:31 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2004-02-14 03:45:31 +0800
commitfdacdc0bb9a57096680d44ff92aa24ff997bbff4 (patch)
treecc85ea0d2d800d3e660fb062570d0d9b79414564 /camel/providers/local/camel-local-store.c
parentbab092a05cc6b1c7d11954bfb65d2b0aa6d1ce6f (diff)
downloadgsoc2013-evolution-fdacdc0bb9a57096680d44ff92aa24ff997bbff4.tar
gsoc2013-evolution-fdacdc0bb9a57096680d44ff92aa24ff997bbff4.tar.gz
gsoc2013-evolution-fdacdc0bb9a57096680d44ff92aa24ff997bbff4.tar.bz2
gsoc2013-evolution-fdacdc0bb9a57096680d44ff92aa24ff997bbff4.tar.lz
gsoc2013-evolution-fdacdc0bb9a57096680d44ff92aa24ff997bbff4.tar.xz
gsoc2013-evolution-fdacdc0bb9a57096680d44ff92aa24ff997bbff4.tar.zst
gsoc2013-evolution-fdacdc0bb9a57096680d44ff92aa24ff997bbff4.zip
Same.
2004-02-13 Jeffrey Stedfast <fejj@ximian.com> * providers/imap/camel-imap-store.c (get_folder_online): Same. * providers/local/camel-mh-store.c (get_folder): Same as maildir changes. * providers/local/camel-maildir-store.c (get_folder): Make exceptions strings consistanmt with the mbox exception strings (and vise versa). Also handle the CAMEL_STORE_FOLDER_EXCL flag. * providers/local/camel-mbox-store.c (get_folder): Check CAMEL_STORE_FOLDER_EXCL flag. * providers/local/camel-local-store.c (get_folder): Simplified by using camel_mkdir instead of doing it manually. * camel-store.c (camel_store_get_folder): If the folder exists in the cache and the O_EXCL flag was passed, return NULL and set an exception. * camel-store.h: Added a new CAMEL_STORE_FOLDER_EXCL flag for use with get_folder(). svn path=/trunk/; revision=24738
Diffstat (limited to 'camel/providers/local/camel-local-store.c')
-rw-r--r--camel/providers/local/camel-local-store.c34
1 files changed, 11 insertions, 23 deletions
diff --git a/camel/providers/local/camel-local-store.c b/camel/providers/local/camel-local-store.c
index 09b644a318..fae124e448 100644
--- a/camel/providers/local/camel-local-store.c
+++ b/camel/providers/local/camel-local-store.c
@@ -39,6 +39,7 @@
#include "camel-local-folder.h"
#include <camel/camel-text-index.h>
+#include <camel/camel-file-utils.h>
#define d(x)
@@ -129,10 +130,9 @@ camel_local_store_get_toplevel_dir (CamelLocalStore *store)
static CamelFolder *
get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelException * ex)
{
- struct stat st;
char *path = ((CamelLocalStore *)store)->toplevel_dir;
- char *sub, *slash;
-
+ struct stat st;
+
if (path[0] != '/') {
camel_exception_setv(ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
_("Store root %s is not an absolute path"), path);
@@ -155,27 +155,15 @@ get_folder(CamelStore * store, const char *folder_name, guint32 flags, CamelExce
path, g_strerror (errno));
return NULL;
}
-
+
/* need to create the dir heirarchy */
- sub = g_alloca (strlen (path) + 1);
- strcpy (sub, path);
- slash = sub;
- do {
- slash = strchr (slash + 1, '/');
- if (slash)
- *slash = 0;
- if (stat (sub, &st) == -1) {
- if (errno != ENOENT || mkdir (sub, 0700) == -1) {
- camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
- _("Cannot get folder: %s: %s"),
- path, g_strerror (errno));
- return NULL;
- }
- }
- if (slash)
- *slash = '/';
- } while (slash);
-
+ if (camel_mkdir (path, 0777) == -1 && errno != EEXIST) {
+ camel_exception_setv (ex, CAMEL_EXCEPTION_STORE_NO_FOLDER,
+ _("Cannot get folder: %s: %s"),
+ path, g_strerror (errno));
+ return NULL;
+ }
+
return (CamelFolder *) 0xdeadbeef;
}