diff options
author | bertrand <Bertrand.Guiheneuf@aful.org> | 1999-08-05 00:36:54 +0800 |
---|---|---|
committer | Bertrand Guiheneuf <bertrand@src.gnome.org> | 1999-08-05 00:36:54 +0800 |
commit | b92cd47ad5105869b66b2166e2dafecbf8d29c93 (patch) | |
tree | 4dbb4d18f49594b603155abd4696e1dc286f99d1 | |
parent | 8a9862a5504e3987af99b9a444ca141736051c4d (diff) | |
download | gsoc2013-evolution-b92cd47ad5105869b66b2166e2dafecbf8d29c93.tar.gz gsoc2013-evolution-b92cd47ad5105869b66b2166e2dafecbf8d29c93.tar.zst gsoc2013-evolution-b92cd47ad5105869b66b2166e2dafecbf8d29c93.zip |
finshed implementation (_delete_messages): implemented.
1999-08-04 bertrand <Bertrand.Guiheneuf@aful.org>
* camel/providers/MH/camel-mh-folder.c (_delete):
finshed implementation
(_delete_messages): implemented.
svn path=/trunk/; revision=1076
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | camel/camel-stream-fs.c | 2 | ||||
-rw-r--r-- | camel/providers/MH/camel-mh-folder.c | 101 |
3 files changed, 100 insertions, 11 deletions
@@ -1,9 +1,17 @@ +1999-08-04 bertrand <Bertrand.Guiheneuf@aful.org> + + * camel/providers/MH/camel-mh-folder.c (_delete): + finshed implementation + (_delete_messages): implemented. + + 1999-08-04 Robert Brady <rwb197@ecs.soton.ac.uk> * camel/gmime-rfc2047.[ch]: added an implemention of RFC2047 (support for character sets other than US-ASCII in MIME headers). Not actually called from anywhere yet. + 1999-08-03 bertrand <Bertrand.Guiheneuf@aful.org> * camel/providers/MH/camel-mh-folder.c (_create): diff --git a/camel/camel-stream-fs.c b/camel/camel-stream-fs.c index 0e006a28f3..a8e0dcb6c4 100644 --- a/camel/camel-stream-fs.c +++ b/camel/camel-stream-fs.c @@ -118,7 +118,7 @@ camel_stream_fs_new_with_name (gchar *name, CamelStreamFsMode mode) fd = open (name, flags, 0600); if (fd==-1) { - CAMEL_LOG_FULL_DEBUG ( "CamelStreamFs::new_with_name can not obtain fd for file \"%s\"\n", name); + CAMEL_LOG_WARNING ( "CamelStreamFs::new_with_name can not obtain fd for file \"%s\"\n", name); CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); return NULL; } diff --git a/camel/providers/MH/camel-mh-folder.c b/camel/providers/MH/camel-mh-folder.c index 206636578b..8027be95b6 100644 --- a/camel/providers/MH/camel-mh-folder.c +++ b/camel/providers/MH/camel-mh-folder.c @@ -21,14 +21,17 @@ * USA */ -#include "camel-mh-folder.h" -#include "camel-mh-store.h" -#include "gstring-util.h" -#include <sys/stat.h> +#include <sys/stat.h> #include <unistd.h> #include <sys/types.h> #include <fcntl.h> - +#include <dirent.h> +#include <stdio.h> +#include <errno.h> +#include "camel-mh-folder.h" +#include "camel-mh-store.h" +#include "gstring-util.h" +#include "camel-log.h" static CamelFolderClass *parent_class=NULL; @@ -42,6 +45,8 @@ static void _set_name(CamelFolder *folder, const gchar *name); static void _init_with_store (CamelFolder *folder, CamelStore *parent_store); static gboolean _exists (CamelFolder *folder); static gboolean _create(CamelFolder *folder); +static gboolean _delete (CamelFolder *folder, gboolean recurse); +static gboolean _delete_messages (CamelFolder *folder); static void camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) @@ -55,6 +60,8 @@ camel_mh_folder_class_init (CamelMhFolderClass *camel_mh_folder_class) camel_folder_class->init_with_store = _init_with_store; camel_folder_class->set_name = _set_name; camel_folder_class->exists = _exists; + camel_folder_class->delete = _delete; + camel_folder_class->delete_messages = _delete_messages; } @@ -159,7 +166,7 @@ _exists (CamelFolder *folder) static gboolean -_create(CamelFolder *folder) +_create (CamelFolder *folder) { CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); const gchar *directory_path; @@ -188,19 +195,93 @@ _delete (CamelFolder *folder, gboolean recurse) CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); const gchar *directory_path; - gint rmdir_error; - + gint rmdir_error = 0; + g_assert(folder); /* call default implementation */ parent_class->delete (folder, recurse); - + /* the default implementation will care about deleting + messages first and recursing the operation if + necessary */ + directory_path = mh_folder->directory_path; if (!directory_path) return FALSE; if (!camel_folder_exists (folder)) return TRUE; - + /* physically delete the directory */ + CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete removing directory %s\n", directory_path); rmdir_error = rmdir (directory_path); + if (rmdir_error == -1) { + CAMEL_LOG_FULL_WARNING ("CamelMhFolder::delete Error when removing directory %s\n", directory_path); + CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); + } + + return (rmdir_error != -1); +} + + +static gboolean +_delete_messages (CamelFolder *folder) +{ + + CamelMhFolder *mh_folder = CAMEL_MH_FOLDER(folder); + const gchar *directory_path; + struct stat stat_buf; + gint stat_error = 0; + GList *file_list; + gchar *entry_name; + struct dirent *dir_entry; + gint unlink_error = 0; + DIR *dir_handle; + + g_assert(folder); + + /* call default implementation */ + parent_class->delete_messages (folder); + + directory_path = mh_folder->directory_path; + if (!directory_path) return FALSE; + + if (!camel_folder_exists (folder)) return TRUE; + + dir_handle = opendir (directory_path); + + /* read first entry in the directory */ + dir_entry = readdir (dir_handle); + while ((stat_error != -1) && (unlink_error != -1) && (dir_entry != NULL)) { + + /* get the name of the next entry in the dir */ + entry_name = dir_entry->d_name; + stat_error = stat (mh_folder->directory_path, &stat_buf); + + /* is it a regular file ? */ + if ((stat_error != -1) && S_ISREG(stat_buf.st_mode)) { + /* yes, delete it */ + CAMEL_LOG_FULL_DEBUG ("CamelMhFolder::delete_messages removing file %s\n", entry_name); + unlink_error = unlink(entry_name); + + if (unlink_error == -1) { + CAMEL_LOG_FULL_WARNING ("CamelMhFolder::delete_messages Error when deleting file %s\n", entry_name); + CAMEL_LOG_FULL_DEBUG ( " Full error text is : %s\n", strerror(errno)); + } + } + /* read next entry */ + dir_entry = readdir (dir_handle); + } + + closedir (dir_handle); + + return ((stat_error != -1) && (unlink_error != -1)); } + + + + + + + + + |