[evolution-data-server] [Maildir] Change flag separator in file name for Win32
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] [Maildir] Change flag separator in file name for Win32
- Date: Fri, 6 Nov 2015 21:40:08 +0000 (UTC)
commit 5234b1f9af08f68cd2d4f757b3898180ccc6fe3a
Author: Milan Crha <mcrha redhat com>
Date: Fri Nov 6 22:38:40 2015 +0100
[Maildir] Change flag separator in file name for Win32
The ':' is not allowed in the file name, use '!' instead.
camel/providers/local/camel-maildir-folder.c | 2 +-
camel/providers/local/camel-maildir-summary.c | 16 ++++++++--------
camel/providers/local/camel-maildir-summary.h | 8 ++++++++
3 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/camel/providers/local/camel-maildir-folder.c b/camel/providers/local/camel-maildir-folder.c
index 14580ae..31ca0d0 100644
--- a/camel/providers/local/camel-maildir-folder.c
+++ b/camel/providers/local/camel-maildir-folder.c
@@ -132,7 +132,7 @@ maildir_folder_get_filename (CamelFolder *folder,
gint uid_len = strlen (uid);
while (filename = g_dir_read_name (dir), filename) {
- if (g_str_has_prefix (filename, uid) && (filename[uid_len] == '\0' ||
filename[uid_len] == ':')) {
+ if (g_str_has_prefix (filename, uid) && (filename[uid_len] == '\0' ||
filename[uid_len] == CAMEL_MAILDIR_FLAG_SEP)) {
camel_maildir_info_set_filename (mdi, g_strdup (filename));
break;
}
diff --git a/camel/providers/local/camel-maildir-summary.c b/camel/providers/local/camel-maildir-summary.c
index 8e977e5..b93a65d 100644
--- a/camel/providers/local/camel-maildir-summary.c
+++ b/camel/providers/local/camel-maildir-summary.c
@@ -217,8 +217,8 @@ gchar *camel_maildir_summary_info_to_name (const CamelMaildirMessageInfo *info)
gint i;
uid = camel_message_info_uid (info);
- buf = g_alloca (strlen (uid) + strlen (":2,") + G_N_ELEMENTS (flagbits) + 1);
- p = buf + sprintf (buf, "%s:2,", uid);
+ buf = g_alloca (strlen (uid) + strlen (CAMEL_MAILDIR_FLAG_SEP_S "2,") + G_N_ELEMENTS (flagbits) + 1);
+ p = buf + sprintf (buf, "%s" CAMEL_MAILDIR_FLAG_SEP_S "2,", uid);
for (i = 0; i < G_N_ELEMENTS (flagbits); i++) {
if (info->info.info.flags & flagbits[i].flagbit)
*p++ = flagbits[i].flag;
@@ -237,7 +237,7 @@ gint camel_maildir_summary_name_to_info (CamelMaildirMessageInfo *info, const gc
/*guint32 all = 0;*/ /* all flags */
gint i;
- p = strstr (name, ":2,");
+ p = strstr (name, CAMEL_MAILDIR_FLAG_SEP_S "2,");
if (p) {
p+=3;
@@ -414,7 +414,7 @@ static gchar *maildir_summary_next_uid_string (CamelFolderSummary *s)
if (mds->priv->current_file) {
gchar *cln;
- cln = strchr (mds->priv->current_file, ':');
+ cln = strchr (mds->priv->current_file, CAMEL_MAILDIR_FLAG_SEP);
if (cln)
return g_strndup (mds->priv->current_file, cln - mds->priv->current_file);
else
@@ -487,7 +487,7 @@ maildir_summary_load (CamelLocalSummary *cls,
continue;
/* map the filename -> uid */
- uid = strchr (d->d_name, ':');
+ uid = strchr (d->d_name, CAMEL_MAILDIR_FLAG_SEP);
if (uid) {
gint len = uid - d->d_name;
uid = camel_mempool_alloc (pool, len + 1);
@@ -660,7 +660,7 @@ maildir_summary_check (CamelLocalSummary *cls,
continue;
/* map the filename -> uid */
- uid = strchr (d->d_name, ':');
+ uid = strchr (d->d_name, CAMEL_MAILDIR_FLAG_SEP);
if (uid)
uid = g_strndup (d->d_name, uid - d->d_name);
else
@@ -741,7 +741,7 @@ maildir_summary_check (CamelLocalSummary *cls,
} else {
gchar *nm;
newname = g_strdup (name);
- nm =strrchr (newname, ':');
+ nm =strrchr (newname, CAMEL_MAILDIR_FLAG_SEP);
if (nm)
*nm = '\0';
destname = newname;
@@ -749,7 +749,7 @@ maildir_summary_check (CamelLocalSummary *cls,
/* copy this to the destination folder, use 'standard' semantics for maildir info
field */
src = g_strdup_printf ("%s/%s", new, name);
- destfilename = g_strdup_printf ("%s:2,", destname);
+ destfilename = g_strdup_printf ("%s" CAMEL_MAILDIR_FLAG_SEP_S "2,", destname);
dest = g_strdup_printf ("%s/%s", cur, destfilename);
/* FIXME: This should probably use link/unlink */
diff --git a/camel/providers/local/camel-maildir-summary.h b/camel/providers/local/camel-maildir-summary.h
index a20a04e..77cbdd3 100644
--- a/camel/providers/local/camel-maildir-summary.h
+++ b/camel/providers/local/camel-maildir-summary.h
@@ -40,6 +40,14 @@
(G_TYPE_INSTANCE_GET_CLASS \
((obj), CAMEL_TYPE_MAILDIR_SUMMARY, CamelMaildirSummaryClass))
+#ifdef G_OS_WIN32
+#define CAMEL_MAILDIR_FLAG_SEP '!'
+#define CAMEL_MAILDIR_FLAG_SEP_S "!"
+#else
+#define CAMEL_MAILDIR_FLAG_SEP ':'
+#define CAMEL_MAILDIR_FLAG_SEP_S ":"
+#endif
+
G_BEGIN_DECLS
typedef struct _CamelMaildirSummary CamelMaildirSummary;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]