diff options
author | Iain Holmes <iain@src.gnome.org> | 2001-07-17 04:43:38 +0800 |
---|---|---|
committer | Iain Holmes <iain@src.gnome.org> | 2001-07-17 04:43:38 +0800 |
commit | 86b0cdbb0738cc8b188abad6429ef80d64c9ed0d (patch) | |
tree | 1f1f48d377c03ed4813efb9f12a33f61b0e90002 /importers | |
parent | ac81c90d1e63beff476114bb288edd0844e5ca06 (diff) | |
download | gsoc2013-evolution-86b0cdbb0738cc8b188abad6429ef80d64c9ed0d.tar gsoc2013-evolution-86b0cdbb0738cc8b188abad6429ef80d64c9ed0d.tar.gz gsoc2013-evolution-86b0cdbb0738cc8b188abad6429ef80d64c9ed0d.tar.bz2 gsoc2013-evolution-86b0cdbb0738cc8b188abad6429ef80d64c9ed0d.tar.lz gsoc2013-evolution-86b0cdbb0738cc8b188abad6429ef80d64c9ed0d.tar.xz gsoc2013-evolution-86b0cdbb0738cc8b188abad6429ef80d64c9ed0d.tar.zst gsoc2013-evolution-86b0cdbb0738cc8b188abad6429ef80d64c9ed0d.zip |
Don't import if nsmail is empty
svn path=/trunk/; revision=11136
Diffstat (limited to 'importers')
-rw-r--r-- | importers/ChangeLog | 6 | ||||
-rw-r--r-- | importers/netscape-importer.c | 57 |
2 files changed, 60 insertions, 3 deletions
diff --git a/importers/ChangeLog b/importers/ChangeLog index af648d6f94..2b574641ab 100644 --- a/importers/ChangeLog +++ b/importers/ChangeLog @@ -1,3 +1,9 @@ +2001-07-16 Iain Holmes <iain@ximian.com> + + * netscape-importer.c (is_dir_empty): Find out if a dir is either empty + or contains only 0 length files. + (netscape_can_import): Only import a file if the dir isn't empty. + 2001-07-12 Iain Holmes <iain@ximian.com> * netscape-importer.c (netscape_init_prefs): Ignore comments. diff --git a/importers/netscape-importer.c b/importers/netscape-importer.c index b900642241..e8827e1bb1 100644 --- a/importers/netscape-importer.c +++ b/importers/netscape-importer.c @@ -444,7 +444,57 @@ netscape_import_accounts (NetscapeImporter *importer) CORBA_exception_free (&ev); } + +static gboolean +is_dir_empty (const char *path) +{ + DIR *base; + struct stat buf; + struct dirent *contents; + + base = opendir (path); + if (base == NULL) { + return TRUE; /* Can't open dir */ + } + contents = readdir (base); + while (contents != NULL) { + char *fullpath; + + if (strcmp (contents->d_name, ".") == 0 || + strcmp (contents->d_name, "..") == 0) { + contents = readdir (base); + continue; + } + + fullpath = g_concat_dir_and_file (path, contents->d_name); + stat (fullpath, &buf); + if (S_ISDIR (buf.st_mode)) { + gboolean sub; + + sub = is_dir_empty (fullpath); + if (sub == FALSE) { + g_free (fullpath); + closedir (base); + return FALSE; + } + } else { + /* File */ + if (buf.st_size != 0) { + g_free (fullpath); + closedir (base); + return FALSE; + } + } + + g_free (fullpath); + contents = readdir (base); + } + + closedir (base); + return TRUE; +} + static gboolean netscape_can_import (EvolutionIntelligentImporter *ii, void *closure) @@ -477,10 +527,11 @@ netscape_can_import (EvolutionIntelligentImporter *ii, } nsmail_dir = g_hash_table_lookup (user_prefs, "mail.directory"); - if (nsmail_dir == NULL) + if (nsmail_dir == NULL) { return FALSE; - else - return TRUE; + } else { + return is_dir_empty (nsmail_dir); + } } static void |