summaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-19 12:04:12 -0700
committerIra Rice <irarice@gmail.com>2009-01-19 12:04:12 -0700
commit2b5947171bfa4cdad73bb87d7195408fca4e685a (patch)
tree18031046af095edd65b5f4b2c61c944b68767bb6 /src/main.cpp
parentfa007dafa2c499425e7112095cbda9c2ff5ea20c (diff)
downloadmana-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/main.cpp')
-rw-r--r--src/main.cpp48
1 files changed, 39 insertions, 9 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
}
}
}