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
This commit is contained in:
Christian Stimming 2006-09-03 20:14:07 +00:00
parent e6464a1728
commit 3675e7470e
4 changed files with 29 additions and 2 deletions

View File

@ -1,5 +1,10 @@
2006-09-03 Christian Stimming <stimming@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.

View File

@ -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 */

View File

@ -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;
}

View File

@ -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 "