diff options
author | Ira Rice <irarice@gmail.com> | 2009-01-19 12:04:12 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-19 12:04:12 -0700 |
commit | 2b5947171bfa4cdad73bb87d7195408fca4e685a (patch) | |
tree | 18031046af095edd65b5f4b2c61c944b68767bb6 /src | |
parent | fa007dafa2c499425e7112095cbda9c2ff5ea20c (diff) | |
download | mana-client-2b5947171bfa4cdad73bb87d7195408fca4e685a.tar.gz mana-client-2b5947171bfa4cdad73bb87d7195408fca4e685a.tar.bz2 mana-client-2b5947171bfa4cdad73bb87d7195408fca4e685a.tar.xz mana-client-2b5947171bfa4cdad73bb87d7195408fca4e685a.zip |
Fixed a directory creation error reported by our Windows users (why
doesn't PhysFS handle this properly?!?) when there's already an update
directory. Also fixed the recorder class so that it's fixed on Windows
as well.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/main.cpp | 48 | ||||
-rw-r--r-- | src/recorder.h | 20 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 4 |
3 files changed, 51 insertions, 21 deletions
diff --git a/src/main.cpp b/src/main.cpp index ea120fc4..a0066c66 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -101,7 +101,8 @@ #include <sys/stat.h> #endif -namespace { +namespace +{ Window *setupWindow = 0; struct SetupListener : public gcn::ActionListener @@ -186,7 +187,8 @@ void setUpdatesDir() std::stringstream updates; // If updatesHost is currently empty, fill it from config file - if (updateHost.empty()) { + if (updateHost.empty()) + { updateHost = config.getValue("updatehost", "http://www.aethyra.org/updates"); } @@ -198,31 +200,59 @@ void setUpdatesDir() // Parse out any "http://" or "ftp://", and set the updates directory size_t pos; pos = updateHost.find("://"); - if (pos != updateHost.npos) { - if (pos + 3 < updateHost.length()) { + if (pos != updateHost.npos) + { + if (pos + 3 < updateHost.length()) + { updates << "updates/" << updateHost.substr(pos + 3) << "/" << loginData.port; updatesDir = updates.str(); - } else { + } + else + { logger->log(_("Error: Invalid update host: %s"), updateHost.c_str()); errorMessage = _("Invalid update host: ") + updateHost; state = ERROR_STATE; } - } else { + } + else + { logger->log(_("Warning: no protocol was specified for the update host")); - updates << "updates/" << updateHost << "/" << loginData.port; + updates << "updates/" << updateHost << "/" << loginData.port; updatesDir = updates.str(); } ResourceManager *resman = ResourceManager::getInstance(); // Verify that the updates directory exists. Create if necessary. - if (!resman->isDirectory("/" + updatesDir)) { - if (!resman->mkdir("/" + updatesDir)) { + if (!resman->isDirectory("/" + updatesDir)) + { + if (!resman->mkdir("/" + updatesDir)) + { +#if defined WIN32 + std::string newDir = homeDir + "\\" + updatesDir; + std::string::size_type loc = newDir.find("/", 0); + + while (loc != std::string::npos) + { + newDir.replace(loc, 1, "\\"); + loc = newDir.find("/", loc); + } + + if (!CreateDirectory(newDir.c_str(), 0) && + GetLastError() != ERROR_ALREADY_EXISTS) + { + logger->log(_("Error: %s can't be made, but doesn't exist!"), + newDir.c_str()); + errorMessage = _("Error creating updates directory!"); + state = ERROR_STATE; + } +#else logger->log(_("Error: %s/%s can't be made, but doesn't exist!"), homeDir.c_str(), updatesDir.c_str()); errorMessage = _("Error creating updates directory!"); state = ERROR_STATE; +#endif } } } diff --git a/src/recorder.h b/src/recorder.h index fe49810f..eeaf4821 100644 --- a/src/recorder.h +++ b/src/recorder.h @@ -31,18 +31,18 @@ class ChatWindow; class Recorder : public ButtonBoxListener { + private: + ChatWindow *mChat; + std::ofstream mStream; + ButtonBox *mButtonBox; public: Recorder(ChatWindow *chat); - void record(const std::string &msg); - void respond(const std::string &msg); - void help() const; - void help(const std::string &args) const; - void buttonBoxRespond(); - bool isRecording() const {return mStream.is_open();} + void record(const std::string &msg); + void respond(const std::string &msg); + void help() const; + void help(const std::string &args) const; + void buttonBoxRespond(); + bool isRecording() {return (bool) mStream.is_open();} virtual ~Recorder(); - private: - ChatWindow *mChat; - std::ofstream mStream; - ButtonBox *mButtonBox; }; #endif diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 99b84506..7f2cba1d 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -153,8 +153,8 @@ bool ResourceManager::addToSearchPath(const std::string &path, bool append) } void ResourceManager::searchAndAddArchives(const std::string &path, - const std::string &ext, - bool append) + const std::string &ext, + bool append) { const char *dirSep = PHYSFS_getDirSeparator(); char **list = PHYSFS_enumerateFiles(path.c_str()); |