diff options
Diffstat (limited to 'camel/providers/local/camel-mbox-folder.c')
-rw-r--r-- | camel/providers/local/camel-mbox-folder.c | 69 |
1 files changed, 68 insertions, 1 deletions
diff --git a/camel/providers/local/camel-mbox-folder.c b/camel/providers/local/camel-mbox-folder.c index 942610d5a9..159ae353d7 100644 --- a/camel/providers/local/camel-mbox-folder.c +++ b/camel/providers/local/camel-mbox-folder.c @@ -1,6 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8; fill-column: 160 -*- * * Authors: Michael Zucchi <notzed@ximian.com> + * Jeffrey Stedfast <fejj@ximian.com> * * Copyright (C) 1999, 2003 Ximian Inc. * @@ -51,6 +52,9 @@ static CamelLocalFolderClass *parent_class = NULL; #define CF_CLASS(so) CAMEL_FOLDER_CLASS (CAMEL_OBJECT_GET_CLASS(so)) #define CMBOXS_CLASS(so) CAMEL_STORE_CLASS (CAMEL_OBJECT_GET_CLASS(so)) +char *camel_mbox_folder_get_full_path (const char *toplevel_dir, const char *full_name); +char *camel_mbox_folder_get_meta_path (const char *toplevel_dir, const char *full_name, const char *ext); + static int mbox_lock(CamelLocalFolder *lf, CamelLockType type, CamelException *ex); static void mbox_unlock(CamelLocalFolder *lf); @@ -86,7 +90,9 @@ camel_mbox_folder_class_init(CamelMboxFolderClass * camel_mbox_folder_class) #endif camel_folder_class->set_message_user_flag = mbox_set_message_user_flag; camel_folder_class->set_message_user_tag = mbox_set_message_user_tag; - + + lclass->get_full_path = camel_mbox_folder_get_full_path; + lclass->get_meta_path = camel_mbox_folder_get_meta_path; lclass->create_summary = mbox_create_summary; lclass->lock = mbox_lock; lclass->unlock = mbox_unlock; @@ -140,6 +146,67 @@ camel_mbox_folder_new(CamelStore *parent_store, const char *full_name, guint32 f return folder; } +char * +camel_mbox_folder_get_full_path (const char *toplevel_dir, const char *full_name) +{ + const char *inptr = full_name; + int subdirs = 0; + char *path, *p; + + while (*inptr != '\0') { + if (*inptr == '/') + subdirs++; + inptr++; + } + + path = g_malloc (strlen (toplevel_dir) + (inptr - full_name) + (4 * subdirs) + 1); + p = g_stpcpy (path, toplevel_dir); + + inptr = full_name; + while (*inptr != '\0') { + while (*inptr != '/' && *inptr != '\0') + *p++ = *inptr++; + + if (*inptr == '/') { + p = g_stpcpy (p, ".sbd/"); + inptr++; + + /* strip extranaeous '/'s */ + while (*inptr == '/') + inptr++; + } + } + + *p = '\0'; + + return path; +} + +char * +camel_mbox_folder_get_meta_path (const char *toplevel_dir, const char *full_name, const char *ext) +{ +/*#define USE_HIDDEN_META_FILES*/ +#ifdef USE_HIDDEN_META_FILES + char *name, *slash; + + name = g_alloca (strlen (full_name) + strlen (ext) + 2); + if ((slash = strrchr (full_name, '/'))) + sprintf (name, "%.*s.%s%s", slash - full_name + 1, full_name, slash + 1, ext); + else + sprintf (name, ".%s%s", full_name, ext); + + return camel_mbox_folder_get_full_path (toplevel_dir, name); +#else + char *full_path, *path; + + full_path = camel_mbox_folder_get_full_path (toplevel_dir, full_name); + path = g_strdup_printf ("%s%s", full_path, ext); + g_free (full_path); + + return path; +#endif +} + static CamelLocalSummary *mbox_create_summary(const char *path, const char *folder, CamelIndex *index) { return (CamelLocalSummary *)camel_mbox_summary_new(path, folder, index); |