r15430 - gnucash/trunk/src - Replace access by _waccess on Windows. Fix leak from r15429.

Andreas Köhler andi5 at cvs.gnucash.org
Fri Jan 26 18:35:31 EST 2007


Author: andi5
Date: 2007-01-26 18:35:29 -0500 (Fri, 26 Jan 2007)
New Revision: 15430
Trac: http://svn.gnucash.org/trac/changeset/15430

Modified:
   gnucash/trunk/src/backend/file/gnc-backend-file.c
   gnucash/trunk/src/import-export/qif-import/druid-qif-import.c
Log:
Replace access by _waccess on Windows. Fix leak from r15429.

As g_access is new in GLib 2.8, use _waccess directly. Also free the
results of g_utf8_to_utf16.


Modified: gnucash/trunk/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.c	2007-01-26 22:29:42 UTC (rev 15429)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.c	2007-01-26 23:35:29 UTC (rev 15430)
@@ -299,6 +299,7 @@
 	    PWARN("Error on chmod(%s): %d: %s", be->lockfile,
 		  errno, strerror(errno) ? strerror(errno) : "");
 	}
+	g_free (wlock);
 #endif
 	rv = g_unlink (be->lockfile);
 	if (rv) {

Modified: gnucash/trunk/src/import-export/qif-import/druid-qif-import.c
===================================================================
--- gnucash/trunk/src/import-export/qif-import/druid-qif-import.c	2007-01-26 22:29:42 UTC (rev 15429)
+++ gnucash/trunk/src/import-export/qif-import/druid-qif-import.c	2007-01-26 23:35:29 UTC (rev 15430)
@@ -449,6 +449,7 @@
 
   const char * path_to_load;
   const gchar * default_acctname = NULL;
+  int rv;
 
   SCM make_qif_file   = scm_c_eval_string("make-qif-file");
   SCM qif_file_load   = scm_c_eval_string("qif-file:read-file");
@@ -476,7 +477,17 @@
     gnc_error_dialog(wind->window, _("Please select a file to load."));
     return TRUE;
   }
-  else if ((strlen(path_to_load) > 0) && access(path_to_load, R_OK) < 0) {
+
+#ifdef G_OS_WIN32
+  {
+    wchar_t *wpath = g_utf8_to_utf16(path_to_load, -1, NULL, NULL, NULL);
+    rv = wpath ? _waccess(wpath, R_OK) : -1;
+    g_free(wpath);
+  }
+#else
+  rv = access(path_to_load, R_OK);
+#endif
+  if (rv < 0) {
     /* stay here if bad file */
     gnc_error_dialog(wind->window, 
 		     _("File not found or read permission denied. "



More information about the gnucash-changes mailing list