aboutsummaryrefslogtreecommitdiffstats
path: root/mail/importers/mail-importer.c
diff options
context:
space:
mode:
authorTor Lillqvist <tml@novell.com>2005-12-18 02:35:37 +0800
committerTor Lillqvist <tml@src.gnome.org>2005-12-18 02:35:37 +0800
commitdf6c612eaa2e2f1b1b691d1f56d7079c9700a826 (patch)
tree43b9e2789ee71d340483f87b4c26c9a639dab08a /mail/importers/mail-importer.c
parent20085e766ba79c4ecf7da1ba26dc6e09e2c7450d (diff)
downloadgsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.gz
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.bz2
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.lz
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.xz
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.tar.zst
gsoc2013-evolution-df6c612eaa2e2f1b1b691d1f56d7079c9700a826.zip
importers/elm-importer.c importers/evolution-mbox-importer.c
2005-12-17 Tor Lillqvist <tml@novell.com> * importers/elm-importer.c * importers/evolution-mbox-importer.c * importers/evolution-outlook-importer.c * importers/mail-importer.c * importers/netscape-importer.c * importers/pine-importer.c: Use GLib API when applicable. svn path=/trunk/; revision=30843
Diffstat (limited to 'mail/importers/mail-importer.c')
-rw-r--r--mail/importers/mail-importer.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/mail/importers/mail-importer.c b/mail/importers/mail-importer.c
index e1a7110be7..f317797c1d 100644
--- a/mail/importers/mail-importer.c
+++ b/mail/importers/mail-importer.c
@@ -28,12 +28,14 @@
#include <string.h>
#include <sys/types.h>
-#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
#include <gmodule.h>
#include <libgnome/gnome-util.h>
#include <libgnome/gnome-i18n.h>
@@ -196,7 +198,7 @@ import_mbox_import(struct _mail_msg *mm)
int fd;
CamelMessageInfo *info;
- if (stat(m->path, &st) == -1) {
+ if (g_stat(m->path, &st) == -1) {
g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno));
return;
}
@@ -212,7 +214,7 @@ import_mbox_import(struct _mail_msg *mm)
if (S_ISREG(st.st_mode)) {
CamelOperation *oldcancel = NULL;
- fd = open(m->path, O_RDONLY);
+ fd = g_open(m->path, O_RDONLY|O_BINARY, 0);
if (fd == -1) {
g_warning("cannot find source file to import '%s': %s", m->path, g_strerror(errno));
goto fail1;
@@ -359,13 +361,13 @@ struct _import_folders_data {
static void
import_folders_rec(struct _import_folders_data *m, const char *filepath, const char *folderparent)
{
- DIR *dir;
- struct dirent *d;
+ GDir *dir;
+ const char *d;
struct stat st;
char *filefull, *foldersub, *uri, *utf8_filename;
const char *folder;
- dir = opendir(filepath);
+ dir = g_dir_open(filepath, 0, NULL);
if (dir == NULL)
return;
@@ -373,21 +375,21 @@ import_folders_rec(struct _import_folders_data *m, const char *filepath, const c
camel_operation_start(NULL, _("Scanning %s"), utf8_filename);
g_free (utf8_filename);
- while ( (d=readdir(dir)) ) {
- if (d->d_name[0] == '.')
+ while ( (d=g_dir_read_name(dir))) {
+ if (d[0] == '.')
continue;
- filefull = g_build_filename(filepath, d->d_name, NULL);
+ filefull = g_build_filename(filepath, d, NULL);
/* skip non files and directories, and skip directories in mozilla mode */
- if (stat(filefull, &st) == -1
+ if (g_stat(filefull, &st) == -1
|| !(S_ISREG(st.st_mode)
|| (m->elmfmt && S_ISDIR(st.st_mode)))) {
g_free(filefull);
continue;
}
- folder = d->d_name;
+ folder = d;
if (folderparent == NULL) {
int i;
@@ -412,7 +414,7 @@ import_folders_rec(struct _import_folders_data *m, const char *filepath, const c
g_free(filefull);
filefull = tmp;
- if (stat(filefull, &st) == -1) {
+ if (g_stat(filefull, &st) == -1) {
g_free(filefull);
continue;
}
@@ -426,6 +428,7 @@ import_folders_rec(struct _import_folders_data *m, const char *filepath, const c
g_free(filefull);
}
+ g_dir_close(dir);
camel_operation_end(NULL);
}