summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/files.cc
diff options
context:
space:
mode:
authorSteven Noonan <steven@uplinklabs.net>2009-09-30 00:17:16 -0700
committerSteven Noonan <steven@uplinklabs.net>2009-09-30 00:17:16 -0700
commita98267af0f2c0c556af7ea554c06245d33e04393 (patch)
tree7ab8d44f06293ee9d785e4cb88ad88b8f3f7f379 /crawl-ref/source/files.cc
parent70de00643f964fe0ef4b4f474b11e3ca986e39c9 (diff)
downloadcrawl-ref-a98267af0f2c0c556af7ea554c06245d33e04393.tar.gz
crawl-ref-a98267af0f2c0c556af7ea554c06245d33e04393.zip
files.cc, newgame.cc: support savegame paths with spaces in them
For instance, on Mac OS X, we save to this path: ~/Library/Application Support/Dungeon Crawl Stone Soup But if we just pass this path to an external program via system() without doing anything to it, the app assumes that spaces are intended to indicate separate parameters. We have to escape the paths in one of two ways. UNIX (backslashes): ~/This\ Crappy\ Path\ Has\ Spaces\ In\ It or Windows (doublequotes): "C:\This Crappy Path Has Spaces In It" Signed-off-by: Steven Noonan <steven@uplinklabs.net>
Diffstat (limited to 'crawl-ref/source/files.cc')
-rw-r--r--crawl-ref/source/files.cc14
1 files changed, 10 insertions, 4 deletions
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index e2fcef8895..3b27872c8e 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -693,12 +693,15 @@ std::vector<player_save_info> find_saved_characters()
if (!is_packed_save(filename))
continue;
- const std::string zipname = get_savedir_path(basename);
+ std::string zipname = get_savedir_path(basename);
+ escape_path_spaces(zipname);
// This is the filename we actually read ourselves.
filename = basename + ".sav";
+ escape_path_spaces(filename);
- const std::string dir = get_savedir();
+ std::string dir = get_savedir();
+ escape_path_spaces(dir);
char cmd_buff[1024];
snprintf( cmd_buff, sizeof(cmd_buff), UNPACK_SPECIFIC_FILE_CMD,
@@ -723,8 +726,10 @@ std::vector<player_save_info> find_saved_characters()
filename.substr(0,
filename.length() - strlen(".sav"));
#endif
- const std::string dollname = basename + ".tdl";
+ std::string dollname = basename + ".tdl";
+ const std::string dollpath = get_savedir_path(dollname);
#ifdef LOAD_UNPACKAGE_CMD
+ escape_path_spaces(dollname);
snprintf( cmd_buff, sizeof(cmd_buff),
UNPACK_SPECIFIC_FILE_CMD,
zipname.c_str(),
@@ -732,7 +737,6 @@ std::vector<player_save_info> find_saved_characters()
dollname.c_str() );
system(cmd_buff);
#endif
- const std::string dollpath = get_savedir_path(dollname);
_fill_player_doll(p, dollpath);
#ifdef LOAD_UNPACKAGE_CMD
// Throw away doll file.
@@ -1653,6 +1657,8 @@ void save_game(bool leave_game, const char *farewellmsg)
#ifdef SAVE_PACKAGE_CMD
std::string basename = get_savedir_filename(you.your_name, "", "");
+ escape_path_spaces(basename);
+
char cmd_buff[1024];
snprintf( cmd_buff, sizeof(cmd_buff),