From 889ba4735a0956e36fa73873b45d58b52d24a2e8 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Mon, 24 Sep 2012 22:05:52 -0400 Subject: [PATCH] CCFS: print error when unable to find file by default --- ccfs_gen.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ccfs_gen.py b/ccfs_gen.py index 22b521d..26168f9 100755 --- a/ccfs_gen.py +++ b/ccfs_gen.py @@ -47,6 +47,8 @@ def main(argv): c_file = open(out_fname, 'w') h_file = open(header_fname, 'w') c_file.write('#include \n') + c_file.write('#include \n') + c_file.write('using namespace std;\n') c_file.write('#include "%s"\n' % os.path.basename(header_fname)) for p in paths: c_name = cname(p) @@ -77,7 +79,8 @@ def main(argv): c_file.write('};\n') c_file.write(''' -const unsigned char *CCFSClass::get_file(const char *fname, unsigned int *length) +const unsigned char *CCFSClass::get_file(const char *fname, + unsigned int *length, bool err_on_not_found) { int i; for (i = 0; store[i].fname != NULL; i++) @@ -89,6 +92,8 @@ const unsigned char *CCFSClass::get_file(const char *fname, unsigned int *length return store[i].data; } } + if (err_on_not_found) + cerr << "Error loading file \\"" << fname << '"' << endl; return NULL; } @@ -100,7 +105,8 @@ CCFSClass %s; class CCFSClass { public: - const unsigned char *get_file(const char *fname, unsigned int *length); + const unsigned char *get_file(const char *fname, + unsigned int *length = NULL, bool err_on_not_found = true); }; extern CCFSClass %s;