From 3097feb9fbe7cf65695071bcdff4b7ddb7d3f4a6 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 29 Mar 2010 20:21:38 -0400 Subject: [PATCH] properly creating input file stream --- imbecile.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/imbecile.cc b/imbecile.cc index 4473e7f..cea5ff8 100644 --- a/imbecile.cc +++ b/imbecile.cc @@ -30,7 +30,13 @@ int main(int argc, char * argv[]) } } - ifstream ifs(optarg); + ifstream ifs; + ifs.open(argv[optind], ios::binary); + if (!ifs.is_open()) + { + cerr << "Error opening input file: '" << argv[optind] << "'"; + return 2; + } refptr< vector > ucs_str = deserialize(encoding, ifs); if (ucs_str.isNull()) {