r15407 - gnucash/trunk - Use g_open, g_fopen, g_stat and g_unlink.
Andreas Köhler
andi5 at cvs.gnucash.org
Sun Jan 21 11:38:58 EST 2007
Author: andi5
Date: 2007-01-21 11:38:42 -0500 (Sun, 21 Jan 2007)
New Revision: 15407
Trac: http://svn.gnucash.org/trac/changeset/15407
Modified:
gnucash/trunk/lib/libqof/backend/file/qsf-backend.c
gnucash/trunk/lib/libqof/qof/guid.c
gnucash/trunk/lib/libqof/qof/qofid.h
gnucash/trunk/lib/libqof/qof/qoflog.c
gnucash/trunk/src/app-utils/file-utils.c
gnucash/trunk/src/backend/file/gnc-backend-file.c
gnucash/trunk/src/backend/file/io-example-account.c
gnucash/trunk/src/backend/file/io-gncxml-v2.c
gnucash/trunk/src/backend/file/sixtp.c
gnucash/trunk/src/backend/file/test/test-file-stuff.c
gnucash/trunk/src/backend/file/test/test-load-xml2.c
gnucash/trunk/src/backend/file/test/test-save-in-lang.c
gnucash/trunk/src/backend/file/test/test-xml-account.c
gnucash/trunk/src/backend/file/test/test-xml-commodity.c
gnucash/trunk/src/backend/file/test/test-xml-pricedb.c
gnucash/trunk/src/backend/file/test/test-xml-transaction.c
gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c
gnucash/trunk/src/engine/TransLog.c
gnucash/trunk/src/engine/gnc-filepath-utils.c
gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
gnucash/trunk/src/gnome-utils/gnc-html.c
gnucash/trunk/src/gnome/druid-hierarchy.c
gnucash/trunk/src/import-export/csv/gnc-csv2glist.c
gnucash/trunk/src/import-export/hbci/druid-hbci-initial.c
gnucash/trunk/src/import-export/hbci/gnc-file-aqb-import.c
gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c
gnucash/trunk/src/import-export/qif/qif-file.c
gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
Log:
Use g_open, g_fopen, g_stat and g_unlink.
Replace open, fopen, stat and unlink by their GLib wrappers so that
files on Windows will be handled with the wide character api.
Modified: gnucash/trunk/lib/libqof/backend/file/qsf-backend.c
===================================================================
--- gnucash/trunk/lib/libqof/backend/file/qsf-backend.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/lib/libqof/backend/file/qsf-backend.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -23,6 +23,7 @@
#include "config.h"
#include <glib.h>
+#include <glib/gstdio.h>
#include "qof.h"
#include "qofbackend-p.h"
#include "qof-backend-qsf.h"
@@ -205,7 +206,7 @@
if (!path) { return TRUE; }
if (0 == safe_strcmp(path, QOF_STDOUT)) { return TRUE; }
- if (stat(path, &sbuf) <0) { return FALSE; }
+ if (g_stat(path, &sbuf) <0) { return FALSE; }
if (sbuf.st_size == 0) { return TRUE; }
if(is_our_qsf_object(path)) { return TRUE; }
else if(is_qsf_object(path)) { return TRUE; }
@@ -251,7 +252,7 @@
{
FILE *f;
- f = fopen(qsf_be->fullpath, "a+");
+ f = g_fopen(qsf_be->fullpath, "a+");
if(f) {fclose(f); }
else
{
@@ -472,7 +473,7 @@
params = qsf_be->params;
params->book = book;
path = g_strdup(qsf_be->fullpath);
- f = fopen(path, "r");
+ f = g_fopen(path, "r");
if(!f) { qof_backend_set_error(be, ERR_FILEIO_READ_ERROR); }
fclose(f);
params->filepath = g_strdup(path);
Modified: gnucash/trunk/lib/libqof/qof/guid.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/guid.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/lib/libqof/qof/guid.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -31,8 +31,8 @@
#include <ctype.h>
#include <dirent.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include <stdlib.h>
-#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_TIMES_H
@@ -206,7 +206,7 @@
FILE *fp;
memset(&stats, 0, sizeof(stats));
- if (stat(filename, &stats) != 0)
+ if (g_stat(filename, &stats) != 0)
return 0;
md5_process_bytes(&stats, sizeof(stats), &guid_context);
@@ -215,7 +215,7 @@
if (max_size <= 0)
return total;
- fp = fopen (filename, "r");
+ fp = g_fopen (filename, "r");
if (fp == NULL)
return total;
@@ -265,7 +265,7 @@
continue;
memset(&stats, 0, sizeof(stats));
- if (stat(filename, &stats) != 0)
+ if (g_stat(filename, &stats) != 0)
continue;
md5_process_bytes(&stats, sizeof(stats), &guid_context);
total += sizeof(stats);
@@ -519,7 +519,7 @@
{
FILE *fp;
- fp = fopen ("/dev/urandom", "r");
+ fp = g_fopen ("/dev/urandom", "r");
if (fp == NULL)
return;
Modified: gnucash/trunk/lib/libqof/qof/qofid.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofid.h 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/lib/libqof/qof/qofid.h 2007-01-21 16:38:42 UTC (rev 15407)
@@ -106,7 +106,7 @@
if ((da) && (!(db))) { \
val = 1; \
} \
- val; /* block assumes value of last statment */ \
+ val; /* block assumes value of last statement */ \
})
/** return TRUE if object is of the given type */
Modified: gnucash/trunk/lib/libqof/qof/qoflog.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qoflog.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/lib/libqof/qof/qoflog.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -27,6 +27,7 @@
#include "config.h"
#include <glib.h>
+#include <glib/gstdio.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#else
@@ -90,13 +91,13 @@
{
if(!fout) /* allow qof_log_set_file */
{
- fout = fopen ("/tmp/qof.trace", "w");
+ fout = g_fopen ("/tmp/qof.trace", "w");
}
if(!fout && (filename = (gchar *)g_malloc(MAX_TRACE_FILENAME))) {
snprintf(filename, MAX_TRACE_FILENAME-1, "/tmp/qof.trace.%d",
getpid());
- fout = fopen (filename, "w");
+ fout = g_fopen (filename, "w");
g_free(filename);
}
@@ -153,7 +154,7 @@
else
{
filename = g_strdup(logfilename);
- fout = fopen(filename, "w");
+ fout = g_fopen(filename, "w");
}
qof_log_init();
}
Modified: gnucash/trunk/src/app-utils/file-utils.c
===================================================================
--- gnucash/trunk/src/app-utils/file-utils.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/app-utils/file-utils.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -22,6 +22,7 @@
#include "config.h"
#include <glib.h>
+#include <glib/gstdio.h>
#include <libguile.h>
#include <errno.h>
#include <fcntl.h>
@@ -90,7 +91,7 @@
if (!filename) return 0;
/* Open file: */
- fd = open( filename, O_RDONLY );
+ fd = g_open( filename, O_RDONLY );
g_free(filename); filename = NULL;
Modified: gnucash/trunk/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -32,6 +32,7 @@
#include <glib.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <libintl.h>
#include <locale.h>
#include <stdio.h>
@@ -91,7 +92,7 @@
int rc;
QofBackendError be_err;
- rc = stat (be->lockfile, &statbuf);
+ rc = g_stat (be->lockfile, &statbuf);
if (!rc)
{
/* oops .. file is locked by another user .. */
@@ -99,7 +100,7 @@
return FALSE;
}
- be->lockfd = open (be->lockfile, O_RDWR | O_CREAT | O_EXCL , 0);
+ be->lockfd = g_open (be->lockfile, O_RDWR | O_CREAT | O_EXCL , 0);
if (be->lockfd < 0)
{
/* oops .. we can't create the lockfile .. */
@@ -154,29 +155,29 @@
/* Otherwise, something else is wrong. */
qof_backend_set_error ((QofBackend*)be, ERR_BACKEND_LOCKED);
- unlink (pathbuf);
+ g_unlink (pathbuf);
close (be->lockfd);
- unlink (be->lockfile);
+ g_unlink (be->lockfile);
return FALSE;
}
- rc = stat (be->lockfile, &statbuf);
+ rc = g_stat (be->lockfile, &statbuf);
if (rc)
{
/* oops .. stat failed! This can't happen! */
qof_backend_set_error ((QofBackend*)be, ERR_BACKEND_LOCKED);
- unlink (pathbuf);
+ g_unlink (pathbuf);
close (be->lockfd);
- unlink (be->lockfile);
+ g_unlink (be->lockfile);
return FALSE;
}
if (statbuf.st_nlink != 2)
{
qof_backend_set_error ((QofBackend*)be, ERR_BACKEND_LOCKED);
- unlink (pathbuf);
+ g_unlink (pathbuf);
close (be->lockfd);
- unlink (be->lockfile);
+ g_unlink (be->lockfile);
return FALSE;
}
@@ -218,7 +219,7 @@
int rc;
/* Again check whether the directory can be accessed */
- rc = stat (be->dirname, &statbuf);
+ rc = g_stat (be->dirname, &statbuf);
if (rc != 0 || !S_ISDIR(statbuf.st_mode))
{
/* Error on stat or if it isn't a directory means we
@@ -229,8 +230,8 @@
return;
}
- /* Now check whether we can stat(2) the file itself */
- rc = stat (be->fullpath, &statbuf);
+ /* Now check whether we can g_stat the file itself */
+ rc = g_stat (be->fullpath, &statbuf);
if ((rc != 0) && (!create_if_nonexistent))
{
/* Error on stat means the file doesn't exist */
@@ -277,7 +278,7 @@
ENTER (" ");
if (be->linkfile)
- unlink (be->linkfile);
+ g_unlink (be->linkfile);
if (be->lockfd > 0)
close (be->lockfd);
@@ -286,16 +287,16 @@
int rv;
#ifdef G_OS_WIN32
/* On windows, we need to allow write-access before
- unlink() can succeed */
+ g_unlink() can succeed */
rv = chmod (be->lockfile, S_IWRITE | S_IREAD);
if (rv) {
PWARN("Error on chmod(%s): %d: %s", be->lockfile,
errno, strerror(errno) ? strerror(errno) : "");
}
#endif
- rv = unlink (be->lockfile);
+ rv = g_unlink (be->lockfile);
if (rv) {
- PWARN("Error on unlink(%s): %d: %s", be->lockfile,
+ PWARN("Error on g_unlink(%s): %d: %s", be->lockfile,
errno, strerror(errno) ? strerror(errno) : "");
}
}
@@ -341,7 +342,7 @@
ssize_t count_write;
ssize_t count_read;
- orig_fd = open(orig, O_RDONLY);
+ orig_fd = g_open(orig, O_RDONLY);
if(orig_fd == -1)
{
return FALSE;
@@ -445,10 +446,10 @@
if (!path) { return FALSE; }
if (0 == safe_strcmp(path, QOF_STDOUT)) { return FALSE; }
- t = fopen(path, "r");
+ t = g_fopen(path, "r");
if(!t) { PINFO (" new file"); return TRUE; }
fclose(t);
- rc = stat(path, &sbuf);
+ rc = g_stat(path, &sbuf);
if(rc < 0) { return FALSE; }
if (sbuf.st_size == 0) { PINFO (" empty file"); return TRUE; }
if(gnc_is_xml_data_file_v2(path, NULL)) { return TRUE; }
@@ -469,7 +470,7 @@
datafile = be->fullpath;
- rc = stat (datafile, &statbuf);
+ rc = g_stat (datafile, &statbuf);
if (rc)
return (errno == ENOENT);
@@ -542,8 +543,8 @@
if (gnc_book_write_to_xml_file_v2(book, tmp_name, fbe->file_compression))
{
- /* Record the file's permissions before unlinking it */
- rc = stat(datafile, &statbuf);
+ /* Record the file's permissions before g_unlinking it */
+ rc = g_stat(datafile, &statbuf);
if(rc == 0)
{
/* Use the permissions from the original data file */
@@ -581,7 +582,7 @@
}
#endif
}
- if(unlink(datafile) != 0 && errno != ENOENT)
+ if(g_unlink(datafile) != 0 && errno != ENOENT)
{
qof_backend_set_error(be, ERR_FILEIO_BACKUP_ERROR);
PWARN("unable to unlink filename %s: %s",
@@ -596,7 +597,7 @@
g_free(tmp_name);
return FALSE;
}
- if(unlink(tmp_name) != 0)
+ if(g_unlink(tmp_name) != 0)
{
qof_backend_set_error(be, ERR_BACKEND_PERM);
PWARN("unable to unlink temp filename %s: %s",
@@ -615,7 +616,7 @@
}
else
{
- if(unlink(tmp_name) != 0)
+ if(g_unlink(tmp_name) != 0)
{
switch (errno) {
case ENOENT: /* tmp_name doesn't exist? Assume "RO" error */
@@ -658,7 +659,7 @@
int pathlen;
time_t now;
- if (stat (be->lockfile, &lockstatbuf) != 0)
+ if (g_stat (be->lockfile, &lockstatbuf) != 0)
return;
pathlen = strlen(be->fullpath);
@@ -702,11 +703,11 @@
/* Is a lock file. Skip the active lock file */
(safe_strcmp(name, be->linkfile) != 0) &&
/* Only delete lock files older than the active one */
- (stat(name, &statbuf) == 0) &&
+ (g_stat(name, &statbuf) == 0) &&
(statbuf.st_mtime <lockstatbuf.st_mtime))
{
PINFO ("unlink lock file: %s", name);
- unlink(name);
+ g_unlink(name);
}
else if (be->file_retention_days > 0)
{
@@ -731,8 +732,8 @@
&& file_time > 0
&& days > be->file_retention_days)
{
- PINFO ("unlink stale (%d days old) file: %s", days, name);
- unlink(name);
+ PINFO ("g_unlink stale (%d days old) file: %s", days, name);
+ g_unlink(name);
}
}
}
@@ -930,7 +931,7 @@
/* FIXME: Make sure this doesn't need more sophisticated semantics
* in the face of special file, devices, pipes, symlinks, etc. */
- if (stat(bend->fullpath, &statbuf) == 0) return TRUE;
+ if (g_stat(bend->fullpath, &statbuf) == 0) return TRUE;
return FALSE;
}
Modified: gnucash/trunk/src/backend/file/io-example-account.c
===================================================================
--- gnucash/trunk/src/backend/file/io-example-account.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/io-example-account.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -32,6 +32,7 @@
#include <unistd.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include "sixtp.h"
#include "gnc-engine.h"
@@ -372,7 +373,7 @@
{
FILE *out;
- out = fopen(filename, "w");
+ out = g_fopen(filename, "w");
if (out == NULL)
{
return FALSE;
Modified: gnucash/trunk/src/backend/file/io-gncxml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/io-gncxml-v2.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/io-gncxml-v2.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -22,7 +22,7 @@
#include "config.h"
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
@@ -1239,11 +1239,11 @@
use_gzip = TRUE;
if (!use_gzip)
- return fopen(filename, perms);
+ return g_fopen(filename, perms);
#ifdef G_OS_WIN32
PWARN("Compression not implemented on Windows. Opening uncompressed file.");
- return fopen(filename, perms);
+ return g_fopen(filename, perms);
/* Potential implementation: Windows doesn't have pipe(); use
the g_spawn glib wrappers. */
@@ -1264,7 +1264,7 @@
&child_stdin, NULL, NULL,
&error) ) {
PWARN("G_spawn call failed. Opening uncompressed file.");
- return fopen(filename, perms);
+ return g_fopen(filename, perms);
}
/* FIXME: Now need to set up the child process to write to the
file. */
@@ -1286,14 +1286,14 @@
if (pipe(filedes) < 0) {
PWARN("Pipe call failed. Opening uncompressed file.");
- return fopen(filename, perms);
+ return g_fopen(filename, perms);
}
pid = fork();
switch (pid) {
case -1:
PWARN("Fork call failed. Opening uncompressed file.");
- return fopen(filename, perms);
+ return g_fopen(filename, perms);
case 0: /* child */ {
char buffer[BUFLEN];
@@ -1405,7 +1405,7 @@
{
FILE *out;
- out = fopen(filename, "w");
+ out = g_fopen(filename, "w");
if (out == NULL)
{
return FALSE;
@@ -1428,7 +1428,7 @@
is_gzipped_file(const gchar *name)
{
unsigned char buf[2];
- int fd = open(name, O_RDONLY);
+ int fd = g_open(name, O_RDONLY);
if (fd == -1) {
return FALSE;
Modified: gnucash/trunk/src/backend/file/sixtp.c
===================================================================
--- gnucash/trunk/src/backend/file/sixtp.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/sixtp.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -24,6 +24,7 @@
#include "config.h"
#include <glib.h>
+#include <glib/gstdio.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
@@ -843,7 +844,7 @@
g_return_val_if_fail(filename, FALSE);
g_return_val_if_fail(first_tag, FALSE);
- f = fopen(filename, "r");
+ f = g_fopen(filename, "r");
if (f == NULL) {
return FALSE;
}
Modified: gnucash/trunk/src/backend/file/test/test-file-stuff.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-file-stuff.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/test/test-file-stuff.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -28,10 +28,10 @@
#include <sys/stat.h>
#include <dirent.h>
#include <fcntl.h>
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
+#include <glib/gstdio.h>
#include "gnc-engine.h"
#include "sixtp-dom-parsers.h"
@@ -58,8 +58,8 @@
int fd1, fd2;
int amount_read1, amount_read2;
- fd1 = open(f1, O_RDONLY);
- fd2 = open(f2, O_RDONLY);
+ fd1 = g_open(f1, O_RDONLY);
+ fd2 = g_open(f2, O_RDONLY);
do
{
@@ -372,7 +372,7 @@
{
struct stat file_info;
const char *to_open = argv[count];
- if(stat(to_open, &file_info) != 0)
+ if(g_stat(to_open, &file_info) != 0)
{
printf("cannot stat %s.\n", to_open);
failure("unable to stat file");
Modified: gnucash/trunk/src/backend/file/test/test-load-xml2.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-load-xml2.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/test/test-load-xml2.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -28,7 +28,6 @@
#include "config.h"
#include <stdlib.h>
-#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -36,6 +35,7 @@
#include <string.h>
#include <glib.h>
#include <glib-object.h>
+#include <glib/gstdio.h>
#include "cashobjects.h"
#include "Group.h"
@@ -63,9 +63,9 @@
{
to_remove = g_strdup_printf("%s.LCK", filename);
- if(stat(to_remove, &buf) != -1)
+ if(g_stat(to_remove, &buf) != -1)
{
- unlink(to_remove);
+ g_unlink(to_remove);
}
g_free(to_remove);
}
Modified: gnucash/trunk/src/backend/file/test/test-save-in-lang.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-save-in-lang.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/test/test-save-in-lang.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -1,5 +1,6 @@
#include "config.h"
#include <glib.h>
+#include <glib/gstdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
@@ -153,9 +154,9 @@
struct stat file_info;
char* filename;
- filename = g_strdup_printf("%s/%s", test_dir, next_file);
-
- if(stat(filename, &file_info) != 0)
+ filename = g_build_filename(test_dir, next_file, (gchar*) NULL);
+
+ if(g_stat(filename, &file_info) != 0)
{
failure_args("stat", __FILE__, __LINE__,
"couldn't stat file %s: %s", filename,
Modified: gnucash/trunk/src/backend/file/test/test-xml-account.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-xml-account.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/test/test-xml-account.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -25,7 +25,7 @@
#include "config.h"
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -274,7 +274,7 @@
}
- unlink(filename1);
+ g_unlink(filename1);
g_free(filename1);
xmlFreeNode(test_node);
}
Modified: gnucash/trunk/src/backend/file/test/test-xml-commodity.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-xml-commodity.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/test/test-xml-commodity.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -1,8 +1,8 @@
#include "config.h"
#include <glib.h>
+#include <glib/gstdio.h>
#include <libguile.h>
-#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -204,7 +204,7 @@
/* sixtp_destroy(parser); */
}
- unlink(filename1);
+ g_unlink(filename1);
g_free(filename1);
gnc_commodity_destroy(ran_com);
xmlFreeNode(test_node);
Modified: gnucash/trunk/src/backend/file/test/test-xml-pricedb.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-xml-pricedb.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/test/test-xml-pricedb.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -25,7 +25,7 @@
#include "config.h"
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -116,7 +116,7 @@
}
}
- unlink (filename1);
+ g_unlink (filename1);
g_free (filename1);
xmlFreeNode (test_node);
}
Modified: gnucash/trunk/src/backend/file/test/test-xml-transaction.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-xml-transaction.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/backend/file/test/test-xml-transaction.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -25,7 +25,7 @@
#include "config.h"
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <stdlib.h>
#include <unistd.h>
@@ -473,7 +473,7 @@
/* sixtp_destroy(parser); */
}
- unlink(filename1);
+ g_unlink(filename1);
g_free(filename1);
really_get_rid_of_transaction(ran_trn);
xmlFreeNode(test_node);
Modified: gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c
===================================================================
--- gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/core-utils/gnc-gkeyfile-utils.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -37,7 +37,7 @@
#include "config.h"
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
@@ -97,7 +97,7 @@
contents = g_key_file_to_data(key_file, NULL, NULL);
length = strlen(contents);
- fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ fd = g_open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd == -1) {
if (error) {
*error = g_error_new(G_FILE_ERROR, g_file_error_from_errno(errno),
Modified: gnucash/trunk/src/engine/TransLog.c
===================================================================
--- gnucash/trunk/src/engine/TransLog.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/engine/TransLog.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -25,7 +25,7 @@
#include <errno.h>
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <string.h>
#include "Account.h"
@@ -157,7 +157,7 @@
filename = g_strconcat (log_base_name, ".", timestamp, ".log", NULL);
- trans_log = fopen (filename, "a");
+ trans_log = g_fopen (filename, "a");
if (!trans_log) {
int norr = errno;
printf ("Error: xaccOpenLog(): cannot open journal \n"
Modified: gnucash/trunk/src/engine/gnc-filepath-utils.c
===================================================================
--- gnucash/trunk/src/engine/gnc-filepath-utils.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/engine/gnc-filepath-utils.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -59,8 +59,6 @@
static void
MakeHomeDir (void)
{
- int rc;
- struct stat statbuf;
const gchar *home;
char *path;
char *data;
@@ -71,19 +69,15 @@
path = g_build_filename(home, ".gnucash", (gchar *)NULL);
- rc = stat (path, &statbuf);
- if (rc)
+ if (!g_file_test(path, G_FILE_TEST_EXISTS))
{
- /* assume that the stat failed only because the dir is absent,
- * and not because its read-protected or other error.
- * Go ahead and make it. Don't bother much with checking mkdir
+ /* Go ahead and make it. Don't bother much with checking mkdir
* for errors; seems pointless. */
g_mkdir (path, S_IRWXU); /* perms = S_IRWXU = 0700 */
}
data = g_build_filename (path, "data", (gchar *)NULL);
- rc = stat (data, &statbuf);
- if (rc)
+ if (!g_file_test(data, G_FILE_TEST_EXISTS))
g_mkdir (data, S_IRWXU);
g_free (path);
@@ -182,7 +176,6 @@
char *
xaccResolveFilePath (const char * filefrag)
{
- struct stat statbuf;
char pathbuf[PATH_MAX];
pathGenerator gens[4];
char *filefrag_dup;
@@ -226,8 +219,7 @@
{
gchar *fullpath = g_build_filename(pathbuf, filefrag, (gchar *)NULL);
- int rc = stat (fullpath, &statbuf);
- if ((!rc) && (S_ISREG(statbuf.st_mode)))
+ if (g_file_test(fullpath, G_FILE_TEST_IS_REGULAR))
{
return fullpath;
}
@@ -314,7 +306,7 @@
struct stat statbuf;
gint rc;
- rc = stat (dirname, &statbuf);
+ rc = g_stat (dirname, &statbuf);
if (rc) {
switch (errno) {
case ENOENT:
@@ -328,7 +320,7 @@
dirname, strerror(errno), errno);
exit(1);
}
- stat (dirname, &statbuf);
+ g_stat (dirname, &statbuf);
break;
case EACCES:
Modified: gnucash/trunk/src/gnome/druid-hierarchy.c
===================================================================
--- gnucash/trunk/src/gnome/druid-hierarchy.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/gnome/druid-hierarchy.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -25,6 +25,7 @@
#include <gnome.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
@@ -202,7 +203,7 @@
i = strlen(locale);
ret = g_build_filename(top_dir, locale, (char *)NULL);
- while (stat(ret, &buf) != 0)
+ while (g_stat(ret, &buf) != 0)
{
i--;
if (i<1)
Modified: gnucash/trunk/src/gnome-utils/druid-gconf-setup.c
===================================================================
--- gnucash/trunk/src/gnome-utils/druid-gconf-setup.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/gnome-utils/druid-gconf-setup.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -34,6 +34,7 @@
#include <gnome.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
@@ -138,7 +139,7 @@
g_strfreev(lines);
}
- output = fopen(path_filename, "a");
+ output = g_fopen(path_filename, "a");
if (output == NULL) {
*error = g_error_new (G_FILE_ERROR,
g_file_error_from_errno(errno),
Modified: gnucash/trunk/src/gnome-utils/gnc-html.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-html.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/gnome-utils/gnc-html.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -29,6 +29,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdlib.h>
@@ -1312,7 +1313,7 @@
g_return_val_if_fail (html != NULL, FALSE);
g_return_val_if_fail (filepath != NULL, FALSE);
- fh = fopen (filepath, "w");
+ fh = g_fopen (filepath, "w");
if (!fh)
return FALSE;
Modified: gnucash/trunk/src/import-export/csv/gnc-csv2glist.c
===================================================================
--- gnucash/trunk/src/import-export/csv/gnc-csv2glist.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/import-export/csv/gnc-csv2glist.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -23,7 +23,7 @@
//#include "config.h"
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <string.h>
#include <sys/types.h>
#include <fcntl.h>
@@ -175,7 +175,7 @@
printf("usage:\n\tcsv2glist fname.csv\n");
}
- fp = fopen (argv[1], "r");
+ fp = g_fopen (argv[1], "r");
if (fp == NULL) return 1;
parsed_csv = gnc_csv_parse(fp);
Modified: gnucash/trunk/src/import-export/hbci/druid-hbci-initial.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/druid-hbci-initial.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/import-export/hbci/druid-hbci-initial.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -25,6 +25,7 @@
#include <gnome.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_SYS_WAIT_H
@@ -532,7 +533,7 @@
if (wizard_exists) {
/* Really check whether the file exists */
- int fd = open( wizard_path, O_RDONLY );
+ int fd = g_open( wizard_path, O_RDONLY );
if ( fd == -1)
wizard_exists = FALSE;
else
Modified: gnucash/trunk/src/import-export/hbci/gnc-file-aqb-import.c
===================================================================
--- gnucash/trunk/src/import-export/hbci/gnc-file-aqb-import.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/import-export/hbci/gnc-file-aqb-import.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -27,7 +27,7 @@
#include <glib.h>
#include <glib/gi18n.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <string.h>
#include <sys/time.h>
#include <fcntl.h>
@@ -169,7 +169,7 @@
DEBUG("Filename found: %s",selected_filename);
DEBUG("Opening selected file");
- dtaus_fd = open(selected_filename, O_RDONLY);
+ dtaus_fd = g_open(selected_filename, O_RDONLY);
if (dtaus_fd == -1) {
DEBUG("Could not open file %s", selected_filename);
return;
Modified: gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c
===================================================================
--- gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/import-export/log-replay/gnc-log-replay.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -27,7 +27,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <string.h>
#include <sys/time.h>
#include <libguile.h>
@@ -542,7 +542,7 @@
selected_filename);
} else {
DEBUG("Opening selected file");
- log_file = fopen(selected_filename, "r");
+ log_file = g_fopen(selected_filename, "r");
if(!log_file || ferror(log_file)!=0) {
int err = errno;
perror("File open failed");
Modified: gnucash/trunk/src/import-export/qif/qif-file.c
===================================================================
--- gnucash/trunk/src/import-export/qif/qif-file.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/import-export/qif/qif-file.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -28,7 +28,7 @@
#endif
#include <glib.h>
-#include <stdio.h>
+#include <glib/gstdio.h>
#include <string.h>
#include "gnc-engine.h"
@@ -206,7 +206,7 @@
g_return_val_if_fail(*filename, QIF_E_BADARGS);
/* Open the file */
- fp = fopen(filename, "r");
+ fp = g_fopen(filename, "r");
if (fp == NULL)
return QIF_E_NOFILE;
Modified: gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c 2007-01-21 16:15:41 UTC (rev 15406)
+++ gnucash/trunk/src/report/report-gnome/gnc-plugin-page-report.c 2007-01-21 16:38:42 UTC (rev 15407)
@@ -41,6 +41,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
+#include <glib/gstdio.h>
#include <libguile.h>
#include <sys/stat.h>
#include <errno.h>
@@ -1312,7 +1313,7 @@
if (!filepath)
return NULL;
- rc = stat (filepath, &statbuf);
+ rc = g_stat (filepath, &statbuf);
/* Check for an error that isn't a non-existant file. */
if (rc != 0 && errno != ENOENT)
More information about the gnucash-changes
mailing list