r14884 - gnucash/branches/2.0 - If the file type wasn't recognized, check whether this failed because

Derek Atkins warlord at cvs.gnucash.org
Fri Sep 22 23:09:11 EDT 2006


Author: warlord
Date: 2006-09-22 23:09:09 -0400 (Fri, 22 Sep 2006)
New Revision: 14884
Trac: http://svn.gnucash.org/trac/changeset/14884

Modified:
   gnucash/branches/2.0/
   gnucash/branches/2.0/ChangeLog
   gnucash/branches/2.0/lib/libqof/qof/qofbackend.h
   gnucash/branches/2.0/src/backend/file/gnc-backend-file.c
   gnucash/branches/2.0/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.

Merge from r14791.



Property changes on: gnucash/branches/2.0
___________________________________________________________________
Name: svk:merge
   - d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13334
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282
   + d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/branches/2.0:13335
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13282

Modified: gnucash/branches/2.0/ChangeLog
===================================================================
--- gnucash/branches/2.0/ChangeLog	2006-09-23 03:08:49 UTC (rev 14883)
+++ gnucash/branches/2.0/ChangeLog	2006-09-23 03:09:09 UTC (rev 14884)
@@ -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/branches/2.0/lib/libqof/qof/qofbackend.h
===================================================================
--- gnucash/branches/2.0/lib/libqof/qof/qofbackend.h	2006-09-23 03:08:49 UTC (rev 14883)
+++ gnucash/branches/2.0/lib/libqof/qof/qofbackend.h	2006-09-23 03:09:09 UTC (rev 14884)
@@ -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/branches/2.0/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/branches/2.0/src/backend/file/gnc-backend-file.c	2006-09-23 03:08:49 UTC (rev 14883)
+++ gnucash/branches/2.0/src/backend/file/gnc-backend-file.c	2006-09-23 03:09:09 UTC (rev 14884)
@@ -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/branches/2.0/src/gnome-utils/gnc-file.c
===================================================================
--- gnucash/branches/2.0/src/gnome-utils/gnc-file.c	2006-09-23 03:08:49 UTC (rev 14883)
+++ gnucash/branches/2.0/src/gnome-utils/gnc-file.c	2006-09-23 03:09:09 UTC (rev 14884)
@@ -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