From 3226a2fa6d954c070536375fdc56c9fe109649fe Mon Sep 17 00:00:00 2001 From: Steve Checkoway Date: Tue, 9 Sep 2003 01:00:48 +0000 Subject: [PATCH] Continue OS X installer work. --- stepmania/PBProject/Installer/BuildInstaller.cpp | 16 +++++++++------- stepmania/PBProject/Installer/InstallerFile.h | 3 +++ stepmania/PBProject/Installer/Processor.cpp | 7 +++++++ stepmania/PBProject/Installer/Processor.h | 10 ++++++---- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/stepmania/PBProject/Installer/BuildInstaller.cpp b/stepmania/PBProject/Installer/BuildInstaller.cpp index 3971fa9fff..90884884b7 100644 --- a/stepmania/PBProject/Installer/BuildInstaller.cpp +++ b/stepmania/PBProject/Installer/BuildInstaller.cpp @@ -17,7 +17,7 @@ using namespace std; #include #include -void HandleFile(const char *file, const char *archivePath, bool overwrite) +void HandleFile(const CString& file, const CString& archivePath, bool overwrite) { static bool archiveMade = false; CString command; @@ -29,14 +29,11 @@ void HandleFile(const char *file, const char *archivePath, bool overwrite) archiveMade = true; command = "tar cfP '"; } - command += archivePath; - command += "' '"; - command += file; - command += "'"; + command += archivePath + "' '" + file + "'"; system(command); - printf("%s\n", file); + printf("%s\n", file.c_str()); } void PrintUsage(int err) @@ -75,6 +72,7 @@ int main(int argc, char *argv[]) if (inFile == "help" || inFile == "-h" || inFile == "--help") PrintUsage(0); + outDir += "/files"; InstallerFile config(inFile); unsigned nextLine = 0; @@ -96,11 +94,15 @@ int main(int argc, char *argv[]) CString archivePath = outDir + "/archive.tar"; - Processor p(archivePath, HandleFile, NULL, false); + Processor p(archivePath, HandleFile, NULL, NULL, false); while (nextLine < config.GetNumLines()) p.ProcessLine(config.GetLine(nextLine), nextLine); + /* Compress the archive after it is created */ + command = "gzip '" + archivePath + "'"; + system(command); + if (!config.WriteFile(outDir + "/config")) { printf("%s\n", strerror(errno)); diff --git a/stepmania/PBProject/Installer/InstallerFile.h b/stepmania/PBProject/Installer/InstallerFile.h index 89aeced4b4..4307bd41a6 100644 --- a/stepmania/PBProject/Installer/InstallerFile.h +++ b/stepmania/PBProject/Installer/InstallerFile.h @@ -10,9 +10,12 @@ #ifndef INSTALLER_FILE_H #define INSTALLER_FILE_H +#include "StdString.h" #include #include +using namespace std; + class InstallerFile { private: CString mPath; diff --git a/stepmania/PBProject/Installer/Processor.cpp b/stepmania/PBProject/Installer/Processor.cpp index e2aeefcf01..c7c5e3afab 100644 --- a/stepmania/PBProject/Installer/Processor.cpp +++ b/stepmania/PBProject/Installer/Processor.cpp @@ -209,6 +209,13 @@ void Processor::ProcessLine(const CString& line, unsigned& nextLine) return; } + if (parts[0] == "ASK") + { + if (parts.size() != 3) + goto error; + mVars[parts[1]] = (*mAsk)(parts[2]); + } + error: (*mError)("%s is an invalid command", line.c_str()); ++nextLine; diff --git a/stepmania/PBProject/Installer/Processor.h b/stepmania/PBProject/Installer/Processor.h index f0f2d6ad38..39e43e9d9d 100644 --- a/stepmania/PBProject/Installer/Processor.h +++ b/stepmania/PBProject/Installer/Processor.h @@ -18,9 +18,10 @@ using namespace std; class Processor { private: - typedef void (*handleFileFunc)(const char *file, const char *archivePath, bool overwrite); - typedef const char *(*getPathFunc)(const char *id); + typedef void (*handleFileFunc)(const CString& file, const CString& archivePath, bool overwrite); + typedef const CString (*getPathFunc)(const CString& ID); typedef void (*errorFunc)(const char *fmt, ...); + typedef bool (*askFunc)(const CString& question); stack mReturnStack; bool mDoGoto; @@ -32,6 +33,7 @@ private: CString mCWD; handleFileFunc mHandleFile; getPathFunc mGetPath; + askFunc mAsk; errorFunc mError; bool mInstalling; @@ -39,8 +41,8 @@ private: bool ResolveConditional(const CString& cond); static void DefaultError(const char *fmt, ...); public: - Processor(CString& path, handleFileFunc f, getPathFunc p, bool i) - : mDoGoto(false), mPath(path), mCWD("."), mHandleFile(f), mGetPath(p), + Processor(CString& path, handleFileFunc f, getPathFunc p, askFunc a, bool i) + : mDoGoto(false), mPath(path), mCWD("."), mHandleFile(f), mGetPath(p), mAsk(a), mError(Processor::DefaultError), mInstalling(i) { } void ProcessLine(const CString& line, unsigned& nextLine); void SetErrorFunc(errorFunc f) { mError = f; }