diff options
author | Travis Reitter <travis.reitter@collabora.co.uk> | 2010-09-10 12:13:42 -0700 |
---|---|---|
committer | Travis Reitter <travis.reitter@collabora.co.uk> | 2010-09-10 12:13:42 -0700 |
commit | 17d54039f6b4a505ca83fbfb88b6dcccb9cd9d8f (patch) | |
tree | 02d10f82ee1280b01117fe6c1761e6bc4a5ca6cc /tools | |
parent | e41c4a953bf36bd13ebabb0fb78bd1389b17ef56 (diff) |
Add some more detailed validation/error reporting to the importing tool.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/import-pidgin.vala | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/import-pidgin.vala b/tools/import-pidgin.vala index 22790a4..48a6170 100644 --- a/tools/import-pidgin.vala +++ b/tools/import-pidgin.vala @@ -41,6 +41,33 @@ public class Folks.Importers.Pidgin : Folks.Importer ".purple", "blist.xml", null); } + var file = File.new_for_path (filename); + if (!file.query_exists ()) + { + throw new ImportError.MALFORMED_INPUT ("File %s does not exist.", + filename); + } + + FileInfo file_info; + try + { + file_info = yield file.query_info_async ( + FILE_ATTRIBUTE_ACCESS_CAN_READ, FileQueryInfoFlags.NONE, + Priority.DEFAULT); + } + catch (GLib.Error e) + { + throw new ImportError.MALFORMED_INPUT ( + "Failed to get information about file %s: %s", filename, + e.message); + } + + if (!file_info.get_attribute_boolean (FILE_ATTRIBUTE_ACCESS_CAN_READ)) + { + throw new ImportError.MALFORMED_INPUT ("File %s is not readable.", + filename); + } + Xml.Doc* xml_doc = Parser.parse_file (filename); if (xml_doc == null) |