summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2009-11-25 15:54:57 +0100
committerAdam Borowski <kilobyte@angband.pl>2009-11-25 15:56:09 +0100
commit99e9af0c4242aef7f3cde3274d7b75968b3b245d (patch)
tree39c46701974d3976ac302f34870371ac01128e2b
parent9305aa6caa1ab5da2d0eaa7d720ac7140c97aebb (diff)
downloadcrawl-ref-99e9af0c4242aef7f3cde3274d7b75968b3b245d.tar.gz
crawl-ref-99e9af0c4242aef7f3cde3274d7b75968b3b245d.zip
Remove unportable hacks from the invocation of tar.
-rw-r--r--crawl-ref/source/AppHdr.h6
-rw-r--r--crawl-ref/source/files.cc35
-rw-r--r--crawl-ref/source/files.h4
-rw-r--r--crawl-ref/source/makefile2
4 files changed, 39 insertions, 8 deletions
diff --git a/crawl-ref/source/AppHdr.h b/crawl-ref/source/AppHdr.h
index e2be883659..1b43a1e646 100644
--- a/crawl-ref/source/AppHdr.h
+++ b/crawl-ref/source/AppHdr.h
@@ -461,16 +461,14 @@
// To avoid compression entirely, define SAVE_PACKAGE_NONE.
#ifndef SAVE_PACKAGE_NONE
#ifdef USE_TAR
- // The --absolute-names switch is only there to suppress noise on stdout.
- // All the paths are removed later by --transform.
#define PACKAGE_SUFFIX ".tar.gz"
- #define SAVE_PACKAGE_CMD "tar -zcf %s"PACKAGE_SUFFIX" --remove-files --absolute-names --transform=s:.*/:: %s.*"
+ #define SAVE_PACKAGE_CMD "tar"
#define LOAD_UNPACKAGE_CMD "tar -zxf %s"PACKAGE_SUFFIX" -C %s"
#define UNPACK_SPECIFIC_FILE_CMD LOAD_UNPACKAGE_CMD " %s"
#else
#ifdef USE_ZIP
#define PACKAGE_SUFFIX ".zip"
- #define SAVE_PACKAGE_CMD "/usr/bin/zip -m -q -j -1 %s"PACKAGE_SUFFIX" %s.*"
+ #define SAVE_PACKAGE_CMD "/usr/bin/zip -m -q -j"
#define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s"PACKAGE_SUFFIX" -d %s"
#define UNPACK_SPECIFIC_FILE_CMD LOAD_UNPACKAGE_CMD " %s"
#endif
diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc
index 896ea8f849..97f00a56f0 100644
--- a/crawl-ref/source/files.cc
+++ b/crawl-ref/source/files.cc
@@ -770,6 +770,22 @@ std::string get_savedir_filename(const std::string &prefix,
{
std::string result = Options.save_dir;
+ result += get_save_filename(prefix, suffix, extension, suppress_uid);
+
+#ifdef TARGET_OS_DOS
+ uppercase(result);
+#endif
+
+ return result;
+}
+
+std::string get_save_filename(const std::string &prefix,
+ const std::string &suffix,
+ const std::string &extension,
+ bool suppress_uid)
+{
+ std::string result = "";
+
// Shorten string as appropriate
result += strip_filename_unsafe_chars(prefix).substr(0, kFileNameLen);
@@ -1681,20 +1697,33 @@ static void _save_game_exit()
clrscr();
#ifdef SAVE_PACKAGE_CMD
- std::string basename = get_savedir_filename(you.your_name, "", "");
+ std::string dirname = get_savedir();
+ escape_path_spaces(dirname);
+ std::string basename = get_save_filename(you.your_name, "", "");
escape_path_spaces(basename);
char cmd_buff[1024];
+#ifdef USE_TAR
snprintf( cmd_buff, sizeof(cmd_buff),
- SAVE_PACKAGE_CMD, basename.c_str(), basename.c_str() );
+ "cd %s && "SAVE_PACKAGE_CMD" -zcf %s"PACKAGE_SUFFIX" --remove-files %s.*",
+ dirname.c_str(), basename.c_str(), basename.c_str());
+#else
+# ifdef USE_ZIP
+ snprintf( cmd_buff, sizeof(cmd_buff),
+ SAVE_PACKAGE_CMD" %s"PACKAGE_SUFFIX" %s.*",
+ (dirname+basename).c_str(), (dirname+basename).c_str());
+# else
+ No save package defined.
+#endif
+#endif
if (system( cmd_buff ) != 0)
{
cprintf( EOL "Warning: Zip command (SAVE_PACKAGE_CMD) returned "
"non-zero value!" EOL );
}
- DO_CHMOD_PRIVATE ( (basename + PACKAGE_SUFFIX).c_str() );
+ DO_CHMOD_PRIVATE ( (dirname + basename + PACKAGE_SUFFIX).c_str() );
#endif
#ifdef DGL_WHEREIS
diff --git a/crawl-ref/source/files.h b/crawl-ref/source/files.h
index 175bc9aa77..d81e23240e 100644
--- a/crawl-ref/source/files.h
+++ b/crawl-ref/source/files.h
@@ -62,6 +62,10 @@ bool travel_load_map( branch_type branch, int absdepth );
std::vector<player_save_info> find_saved_characters();
std::string get_savedir();
+std::string get_save_filename(const std::string &pre,
+ const std::string &suf,
+ const std::string &ext,
+ bool suppress_uid = false);
std::string get_savedir_filename(const std::string &pre,
const std::string &suf,
const std::string &ext,
diff --git a/crawl-ref/source/makefile b/crawl-ref/source/makefile
index d81586e106..1a2364bca8 100644
--- a/crawl-ref/source/makefile
+++ b/crawl-ref/source/makefile
@@ -182,7 +182,7 @@ ifneq (,$(findstring CYGWIN,$(uname_S)))
NO_RDYNAMIC = YesPlease
BUILD_PCRE = YesPlease
endif
-ifneq ($(GAME),crawl.exe)
+ifeq (,$(findstring .exe,$(GAME)))
DEFINES += -DUSE_TAR
else
DEFINES += -DUSE_ZIP