From 1ed7208ad8a498d2c8a5014ec60c25c01a660e55 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Fri, 12 Sep 2003 18:43:04 +0000 Subject: Implements CamelLocalFolder::get_full_path() (publicly namespaced so that 2003-09-12 Jeffrey Stedfast * providers/local/camel-mbox-folder.c (camel_mbox_folder_get_full_path): Implements CamelLocalFolder::get_full_path() (publicly namespaced so that CamelMboxStore can re-use them). (camel_mbox_folder_get_meta_path): Same. * providers/local/camel-mbox-store.c (get_folder): Changed the way the path is constructed, since we now handle subdirectories and stuff. (delete_folder): Try deleting the Folder.sbd directory. We also need to manage our own meta files since CamelLocalStore's impl constructs paths differently than what we need. (create_folder): Implemented. (rename_folder): Implemented. (scan_dir): Scan an mbox tree (get_folder_info): Implemented using scan_dir(). * providers/local/camel-local-store.c (delete_folder): Set fi->url to the correct value, meaning we need to prefix it with the protocol and the folder_name is not actually part of the path, it is a separate component to the url. * providers/local/camel-local-folder.c (camel_local_folder_construct): Use the new class virtual method to construct the full folder path and all the meta files. (local_get_full_path): Implemented default get_full_path method. (local_get_meta_path): Implemented default get_meta_path method. svn path=/trunk/; revision=22557 --- camel/providers/local/camel-mbox-folder.c | 69 ++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'camel/providers/local/camel-mbox-folder.c') 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 + * Jeffrey Stedfast * * 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); -- cgit v1.2.3