From a98267af0f2c0c556af7ea554c06245d33e04393 Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Wed, 30 Sep 2009 00:17:16 -0700 Subject: 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 --- crawl-ref/source/files.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'crawl-ref/source/files.cc') 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 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 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 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), -- cgit v1.2.3-54-g00ecf