diff options
author | Adam Borowski <kilobyte@angband.pl> | 2010-12-14 17:23:20 +0100 |
---|---|---|
committer | Adam Borowski <kilobyte@angband.pl> | 2010-12-16 16:53:02 +0100 |
commit | 203b11eb25997c8e225acac19da9ac206e3d4f48 (patch) | |
tree | 544e67ce4039ac044cfaef7e79f87530c1e58481 /crawl-ref/source/macro.cc | |
parent | 28b815a469419b7ab6ac7d88e7ce41aac34d83da (diff) | |
download | crawl-ref-203b11eb25997c8e225acac19da9ac206e3d4f48.tar.gz crawl-ref-203b11eb25997c8e225acac19da9ac206e3d4f48.zip |
Convert ofstream to fopen() for macro files.
Diffstat (limited to 'crawl-ref/source/macro.cc')
-rw-r--r-- | crawl-ref/source/macro.cc | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 8866fea102..881e851064 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -44,6 +44,8 @@ #include "message.h" #include "state.h" #include "stuff.h" +#include "syscalls.h" +#include "unicode.h" // for trim_string: #include "initfile.h" @@ -650,7 +652,7 @@ int macro_buf_get() return (key); } -static void write_map(std::ofstream &f, const macromap &mp, const char *key) +static void write_map(FILE *f, const macromap &mp, const char *key) { for (macromap::const_iterator i = mp.begin(); i != mp.end(); i++) { @@ -658,8 +660,8 @@ static void write_map(std::ofstream &f, const macromap &mp, const char *key) // macro struct for all used keyboard commands. if (i->second.size()) { - f << key << vtostr((*i).first) << std::endl - << "A:" << vtostr((*i).second) << std::endl << std::endl; + fprintf(f, "%s%s\nA:%s\n\n", OUTS(key), + OUTS(vtostr((*i).first)), OUTS(vtostr((*i).second))); } } } @@ -669,18 +671,21 @@ static void write_map(std::ofstream &f, const macromap &mp, const char *key) */ void macro_save() { - std::ofstream f; + FILE *f; const std::string macrofile = get_macro_file(); - f.open(macrofile.c_str()); + f = fopen_u(macrofile.c_str(), "w"); if (!f) { mprf(MSGCH_ERROR, "Couldn't open %s for writing!", macrofile.c_str()); return; } - f << "# " CRAWL " " << Version::Long() << " macro file" << std::endl - << "# WARNING: This file is entirely auto-generated." << std::endl - << std::endl << "# Key Mappings:" << std::endl; + fprintf(f, "# %s %s macro file\n" + "# WARNING: This file is entirely auto-generated.\n" + "\n" + "# Key Mappings:\n", + OUTS(CRAWL), // ok, localizing the game name is not likely + OUTS(Version::Long())); // nor the version string for (int mc = KMC_DEFAULT; mc < KMC_CONTEXT_COUNT; ++mc) { char keybuf[30] = "K:"; @@ -689,11 +694,11 @@ void macro_save() write_map(f, Keymaps[mc], keybuf); } - f << "# Command Macros:" << std::endl; + fprintf(f, "# Command Macros:\n"); write_map(f, Macros, "M:"); crawl_state.unsaved_macros = false; - f.close(); + fclose(f); } /* |