aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--e-util/ChangeLog7
-rw-r--r--e-util/e-error.c32
-rw-r--r--e-util/e-folder-map.c8
-rw-r--r--e-util/e-fsutils.c28
4 files changed, 42 insertions, 33 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 3ba9753e53..3d912d1b6e 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -3,6 +3,13 @@
* Makefile.am (INCLUDES): Don't need EXTRA_GNOME_CFLAGS or
GNOME_FULL_CFLAGS.
+ * e-error.c
+ * e-fsutils.c: Use gstdio wrappers. Use GDir instead of dirent.
+
+ * e-error.c
+ * e-folder-map.c: Use e_xml_parse_file() instead of using libxml
+ directly.
+
* e-util-private.h (fsync)
* e-util.c: Don't bother with a Win32 implementation of fsync() as
the uses of fsync() in evo are pretty irrelevant. Just #define
diff --git a/e-util/e-error.c b/e-util/e-error.c
index f7dc888609..aff11eef6a 100644
--- a/e-util/e-error.c
+++ b/e-util/e-error.c
@@ -19,13 +19,10 @@
*
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <string.h>
#include <sys/types.h>
-#include <dirent.h>
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
@@ -42,6 +39,9 @@
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-url.h>
+#include <libedataserver/e-xml-utils.h>
+
+#include "e-util-private.h"
#include "e-error.h"
#define d(x)
@@ -159,7 +159,7 @@ map_type(const char *name)
static void
ee_load(const char *path)
{
- xmlDocPtr doc;
+ xmlDocPtr doc = NULL;
xmlNodePtr root, error, scan;
struct _e_error *e;
struct _e_error_button *lastbutton;
@@ -168,7 +168,7 @@ ee_load(const char *path)
d(printf("loading error file %s\n", path));
- doc = xmlParseFile(path);
+ doc = e_xml_parse_file (path);
if (doc == NULL) {
g_warning("Error file '%s' not found", path);
return;
@@ -300,9 +300,9 @@ ee_load(const char *path)
static void
ee_load_tables(void)
{
- DIR *dir;
- struct dirent *d;
- const char *base = EVOLUTION_PRIVDATADIR "/errors";
+ GDir *dir;
+ const char *d;
+ char *base;
struct _e_error_table *table;
int i;
@@ -320,22 +320,26 @@ ee_load_tables(void)
g_hash_table_insert(error_table, table->domain, table);
/* look for installed error tables */
- dir = opendir(base);
- if (dir == NULL)
+ base = g_build_filename (EVOLUTION_PRIVDATADIR, "errors", NULL);
+ dir = g_dir_open(base, 0, NULL);
+ if (dir == NULL) {
+ g_free (base);
return;
+ }
- while ( (d = readdir(dir)) ) {
+ while ( (d = g_dir_read_name(dir)) ) {
char *path;
- if (d->d_name[0] == '.')
+ if (d[0] == '.')
continue;
- path = g_build_filename(base, d->d_name, NULL);
+ path = g_build_filename(base, d, NULL);
ee_load(path);
g_free(path);
}
- closedir(dir);
+ g_dir_close(dir);
+ g_free (base);
}
/* unfortunately, gmarkup_escape doesn't expose its gstring based api :( */
diff --git a/e-util/e-folder-map.c b/e-util/e-folder-map.c
index 8643152a06..28d3f502e3 100644
--- a/e-util/e-folder-map.c
+++ b/e-util/e-folder-map.c
@@ -20,10 +20,7 @@
*
*/
-
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <sys/types.h>
#include <sys/stat.h>
@@ -36,6 +33,8 @@
#include <libxml/parser.h>
#include <libxml/xmlmemory.h>
+#include <libedataserver/e-xml-utils.h>
+
#include "e-folder-map.h"
#define d(x)
@@ -47,7 +46,8 @@ is_type_folder (const char *metadata, const char *search_type)
xmlDocPtr doc;
char *type;
- if (!(doc = xmlParseFile (metadata))) {
+ doc = e_xml_parse_file (metadata);
+ if (!doc) {
g_warning ("Cannot parse `%s'", metadata);
return FALSE;
}
diff --git a/e-util/e-fsutils.c b/e-util/e-fsutils.c
index 923dd5ec42..7d1ddbd0d6 100644
--- a/e-util/e-fsutils.c
+++ b/e-util/e-fsutils.c
@@ -19,14 +19,11 @@
*
*/
-#ifdef HAVE_CONFIG_H
#include <config.h>
-#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
-#include <dirent.h>
/* This isn't as portable as, say, the stuff in GNU coreutils. But I care not for OSF1. */
#ifdef HAVE_STATVFS
@@ -47,6 +44,9 @@
#include <errno.h>
#include <string.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
#include "e-fsutils.h"
/**
@@ -60,8 +60,8 @@
**/
long e_fsutils_usage(const char *inpath)
{
- DIR *dir;
- struct dirent *d;
+ GDir *dir;
+ const char *d;
long size = 0;
GSList *paths;
@@ -73,24 +73,20 @@ long e_fsutils_usage(const char *inpath)
paths = g_slist_remove_link(paths, paths);
- dir = opendir(path);
+ dir = g_dir_open(path, 0, NULL);
if (dir == NULL) {
g_free(path);
goto fail;
}
- while ((d = readdir(dir))) {
+ while ((d = g_dir_read_name(dir))) {
char *full_path;
struct stat st;
- if (strcmp(d->d_name, ".") == 0
- || strcmp(d->d_name, "..") == 0)
- continue;
-
- full_path = g_build_filename(path, d->d_name, NULL);
- if (stat(full_path, &st) == -1) {
+ full_path = g_build_filename(path, d, NULL);
+ if (g_stat(full_path, &st) == -1) {
g_free(full_path);
- closedir(dir);
+ g_dir_close(dir);
g_free(path);
goto fail;
} else if (S_ISDIR(st.st_mode)) {
@@ -99,13 +95,15 @@ long e_fsutils_usage(const char *inpath)
} else if (S_ISREG(st.st_mode)) {
/* This is in 512 byte blocks. st_blksize is page size on linux,
on *BSD it might be significant. */
+#ifndef G_OS_WIN32
size += st.st_blocks/2;
+#endif
}
g_free(full_path);
}
- closedir(dir);
+ g_dir_close(dir);
g_free(path);
}