diff options
-rw-r--r-- | crawl-ref/source/macro.cc | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index dd116d451d..c81dd4330c 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -597,10 +597,16 @@ static void write_map(std::ofstream &f, const macromap &mp, const char *key) /* * Saves macros into the macrofile, overwriting the old one. */ -void macro_save( void ) +void macro_save() { std::ofstream f; - f.open( get_macro_file().c_str() ); + const std::string macrofile = get_macro_file(); + f.open(macrofile.c_str()); + if (!f) + { + mprf(MSGCH_ERROR, "Couldn't open %s for writing!", macrofile.c_str()); + return; + } f << "# WARNING: This file is entirely auto-generated." << std::endl << std::endl << "# Key Mappings:" << std::endl; |