[glom] Command-line parsing: Added some checks.
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [glom] Command-line parsing: Added some checks.
- Date: Mon, 1 Feb 2010 09:19:05 +0000 (UTC)
commit c743dafa405ee7f299b6dba65d9ade324408858d
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Jan 31 20:17:44 2010 +0100
Command-line parsing: Added some checks.
* glom/main.cc: Test the command-line argument filepath for existence and
check that it's not a directory, so it fails before even showing UI.
ChangeLog | 7 +++++++
glom/main.cc | 22 ++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2d33f8c..249499f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2010-01-31 Murray Cumming <murrayc murrayc com>
+ Command-line parsing: Added some checks.
+
+ * glom/main.cc: Test the command-line argument filepath for existence and
+ check that it's not a directory, so it fails before even showing UI.
+
+2010-01-31 Murray Cumming <murrayc murrayc com>
+
Relationships Overview: Avoid GTK+ warnings.
* glom/mode_design/relationships_overview/dialog_relationships_overview.cc:
diff --git a/glom/main.cc b/glom/main.cc
index ebdea96..52c2190 100644
--- a/glom/main.cc
+++ b/glom/main.cc
@@ -539,8 +539,26 @@ main(int argc, char* argv[])
{
//Get a URI (file://something) from the filepath:
Glib::RefPtr<Gio::File> file = Gio::File::create_for_commandline_arg(input_uri);
- if(file)
- input_uri = file->get_uri();
+
+ if(!file->query_exists())
+ {
+ std::cerr << _("Glom: The file does not exist.") << std::endl;
+
+ std::cerr << std::endl << context.get_help() << std::endl;
+ return -1;
+ }
+
+ const Gio::FileType file_type = file->query_file_type();
+ if(file_type == Gio::FILE_TYPE_DIRECTORY)
+ {
+ std::cerr << _("Glom: The file path is a directory instead of a file.") << std::endl;
+
+ std::cerr << std::endl << context.get_help() << std::endl;
+ return -1;
+ }
+
+ input_uri = file->get_uri();
+
//std::cout << "URI = " << input_uri << std::endl;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]