AUDIT: r14791 - gnucash/trunk - If the file type wasn't recognized, check whether this failed because

Christian Stimming cstim at cvs.gnucash.org
Sun Sep 3 16:14:08 EDT 2006


Author: cstim
Date: 2006-09-03 16:14:07 -0400 (Sun, 03 Sep 2006)
New Revision: 14791
Trac: http://svn.gnucash.org/trac/changeset/14791

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/lib/libqof/qof/qofbackend.h
   gnucash/trunk/src/backend/file/gnc-backend-file.c
   gnucash/trunk/src/gnome-utils/gnc-file.c
Log:
If the file type wasn't recognized, check whether this failed because
of no read permission and give appropriate user feedback if yes.
Feel free to adjust the wording.
BP



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-09-03 19:54:50 UTC (rev 14790)
+++ gnucash/trunk/ChangeLog	2006-09-03 20:14:07 UTC (rev 14791)
@@ -1,5 +1,10 @@
 2006-09-03  Christian Stimming  <stimming at tuhh.de>
 
+	* lib/libqof/qof/qofbackend.h, src/gnome-utils/gnc-file.c,
+	src/backend/file/gnc-backend-file.c: If the file type wasn't
+	recognized, check whether this failed because of no read
+	permission and give appropriate user feedback.
+
 	* src/backend/file/gnc-backend-file.c: Fix error checking for
 	non-existing filenames. Will now always give a "file not found"
 	message on nonexisting paths or filenames. #351351.

Modified: gnucash/trunk/lib/libqof/qof/qofbackend.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofbackend.h	2006-09-03 19:54:50 UTC (rev 14790)
+++ gnucash/trunk/lib/libqof/qof/qofbackend.h	2006-09-03 20:14:07 UTC (rev 14791)
@@ -117,6 +117,7 @@
   ERR_FILEIO_WRITE_ERROR,    /**< couldn't write to the file */
   ERR_FILEIO_READ_ERROR,     /**< Could not open the file for reading. */
   ERR_FILEIO_NO_ENCODING,    /**< file does not specify encoding */
+  ERR_FILEIO_FILE_EACCES,    /**< No read access permission for the given file */
 
   /* network errors */
   ERR_NETIO_SHORT_READ = 2000,  /**< not enough bytes received */

Modified: gnucash/trunk/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.c	2006-09-03 19:54:50 UTC (rev 14790)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.c	2006-09-03 20:14:07 UTC (rev 14791)
@@ -879,8 +879,24 @@
         if (FALSE == rc) error = ERR_FILEIO_PARSE_ERROR;
         break;
     default:
-        PWARN("File not any known type");
-        error = ERR_FILEIO_UNKNOWN_FILE_TYPE;
+        /* If file type wasn't known, check errno again to give the
+	   user some more useful feedback for some particular error
+	   conditions. */
+        switch (errno)
+	{
+	case EACCES: /* No read permission */
+	  PWARN("No read permission to file");
+	  error = ERR_FILEIO_FILE_EACCES;
+	  break;
+	case EISDIR: /* File is a directory - but on this error we don't arrive here */
+	  PWARN("Filename is a directory");
+	  error = ERR_FILEIO_FILE_NOT_FOUND;
+	  break;
+	default:
+	  PWARN("File not any known type");
+	  error = ERR_FILEIO_UNKNOWN_FILE_TYPE;
+	  break;
+	}
         break;
     }
 

Modified: gnucash/trunk/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-file.c	2006-09-03 19:54:50 UTC (rev 14790)
+++ gnucash/trunk/src/gnome-utils/gnc-file.c	2006-09-03 20:14:07 UTC (rev 14791)
@@ -443,6 +443,11 @@
       gnc_error_dialog(parent, fmt, newfile);
       break;
 
+    case ERR_FILEIO_FILE_EACCES:
+      fmt = _("No read permission to read from file %s.");
+      gnc_error_dialog (parent, fmt, newfile);
+      break;
+
     case ERR_SQL_DB_TOO_OLD:
       fmt = _("This database is from an older version of GnuCash. "
               "Do you want to want to upgrade the database "



More information about the gnucash-changes mailing list