From 3675e7470e16fc7ba9ce5efd26dfc033be8fe5fc Mon Sep 17 00:00:00 2001 From: Christian Stimming Date: Sun, 3 Sep 2006 20:14:07 +0000 Subject: [PATCH] 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 git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14791 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 5 +++++ lib/libqof/qof/qofbackend.h | 1 + src/backend/file/gnc-backend-file.c | 20 ++++++++++++++++++-- src/gnome-utils/gnc-file.c | 5 +++++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 761afedf3e..6a1ec4c719 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2006-09-03 Christian Stimming + * 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. diff --git a/lib/libqof/qof/qofbackend.h b/lib/libqof/qof/qofbackend.h index b848a478d1..82911329b2 100644 --- a/lib/libqof/qof/qofbackend.h +++ b/lib/libqof/qof/qofbackend.h @@ -117,6 +117,7 @@ typedef enum { 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 */ diff --git a/src/backend/file/gnc-backend-file.c b/src/backend/file/gnc-backend-file.c index a0e841bbb6..32f68c0e68 100644 --- a/src/backend/file/gnc-backend-file.c +++ b/src/backend/file/gnc-backend-file.c @@ -879,8 +879,24 @@ gnc_file_be_load_from_file (QofBackend *bend, QofBook *book) 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; } diff --git a/src/gnome-utils/gnc-file.c b/src/gnome-utils/gnc-file.c index 7f08438d9d..73d10846cf 100644 --- a/src/gnome-utils/gnc-file.c +++ b/src/gnome-utils/gnc-file.c @@ -443,6 +443,11 @@ show_session_error (QofBackendError io_error, 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 "