summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-03-06 23:32:44 +0300
committerAndrei Karas <akaras@inbox.ru>2017-03-06 23:32:44 +0300
commitabe7009c7347dd2821bc687d8eb692bac2609bc2 (patch)
tree89abfab81beff37fc854c2e574a12fe0bc6f92b7
parentba21ad5b52d75c98d15a547a64d246e576c1afc2 (diff)
downloadmv-abe7009c7347dd2821bc687d8eb692bac2609bc2.tar.gz
mv-abe7009c7347dd2821bc687d8eb692bac2609bc2.tar.bz2
mv-abe7009c7347dd2821bc687d8eb692bac2609bc2.tar.xz
mv-abe7009c7347dd2821bc687d8eb692bac2609bc2.zip
Show assert if failed open streamed files.
-rw-r--r--src/client.cpp6
-rw-r--r--src/fs/files.cpp14
-rw-r--r--src/gui/windows/shopwindow.cpp6
-rw-r--r--src/net/packetlimiter.cpp3
-rw-r--r--src/resources/map/map.cpp4
5 files changed, 29 insertions, 4 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 7b54d6823..961287868 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -135,6 +135,7 @@
#include "resources/sprite/spritereference.h"
+#include "utils/checkutils.h"
#include "utils/cpu.h"
#include "utils/delete2.h"
#include "utils/dumplibs.h"
@@ -1904,6 +1905,11 @@ void Client::initTradeFilter()
tradeFile << "i'm trade" << std::endl;
tradeFile << "i'm trading" << std::endl;
}
+ else
+ {
+ reportAlways("Error opening file for writing: %s",
+ tradeListName.c_str());
+ }
tradeFile.close();
}
}
diff --git a/src/fs/files.cpp b/src/fs/files.cpp
index aeb0dd6a4..d8a6e76ec 100644
--- a/src/fs/files.cpp
+++ b/src/fs/files.cpp
@@ -30,6 +30,7 @@
#include "fs/virtlist.h"
#endif // defined(ANDROID) || defined(__native_client__)
+#include "utils/checkutils.h"
#include "utils/stringutils.h"
#include <dirent.h>
@@ -223,7 +224,8 @@ bool Files::loadTextFileLocal(const std::string &fileName,
if (!file.is_open())
{
- logger->log("Couldn't load text file: %s", fileName.c_str());
+ reportAlways("Couldn't load text file: %s",
+ fileName.c_str());
return false;
}
@@ -240,9 +242,17 @@ void Files::saveTextFile(std::string path,
if (!mkdir_r(path.c_str()))
{
std::ofstream file;
- file.open((path.append("/").append(name)).c_str(), std::ios::out);
+ std::string fileName = path.append("/").append(name);
+ file.open(fileName.c_str(), std::ios::out);
if (file.is_open())
+ {
file << text << std::endl;
+ }
+ else
+ {
+ reportAlways("Error opening file for writing: %s",
+ fileName.c_str());
+ }
file.close();
}
}
diff --git a/src/gui/windows/shopwindow.cpp b/src/gui/windows/shopwindow.cpp
index 09686ecaf..0de38a084 100644
--- a/src/gui/windows/shopwindow.cpp
+++ b/src/gui/windows/shopwindow.cpp
@@ -75,6 +75,7 @@
#include "net/tradehandler.h"
#endif // TMWA_SUPPORT
+#include "utils/checkutils.h"
#include "utils/delete2.h"
#include "utils/gettext.h"
@@ -535,6 +536,8 @@ void ShopWindow::loadList()
shopFile.open(shopListName.c_str(), std::ios::in);
if (!shopFile.is_open())
{
+ reportAlways("Error opening file for reading: %s",
+ shopListName.c_str());
shopFile.close();
return;
}
@@ -589,7 +592,8 @@ void ShopWindow::saveList() const
shopFile.open(shopListName.c_str(), std::ios::binary);
if (!shopFile.is_open())
{
- logger->log1("Unable to open shoplist.txt for writing");
+ reportAlways("Error opening file writing: %s",
+ shopListName.c_str());
return;
}
diff --git a/src/net/packetlimiter.cpp b/src/net/packetlimiter.cpp
index 8c34b6919..dd54693b7 100644
--- a/src/net/packetlimiter.cpp
+++ b/src/net/packetlimiter.cpp
@@ -23,6 +23,7 @@
#include "configuration.h"
#include "settings.h"
+#include "utils/checkutils.h"
#include "utils/timer.h"
#include <fstream>
@@ -228,6 +229,8 @@ void PacketLimiter::writePacketLimits(const std::string &packetLimitsName)
outPacketFile.open(packetLimitsName.c_str(), std::ios::out);
if (!outPacketFile.is_open())
{
+ reportAlways("Error opening file for writing: %s",
+ packetLimitsName.c_str());
outPacketFile.close();
return;
}
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 3d47e96fc..b30892048 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -63,6 +63,7 @@
#include "render/renderers.h"
#endif // USE_OPENGL
+#include "utils/checkutils.h"
#include "utils/delete2.h"
#include "utils/dtor.h"
#include "utils/timer.h"
@@ -1221,7 +1222,8 @@ void Map::saveExtraLayer() const restrict2
mapFile.open(mapFileName.c_str(), std::ios::binary);
if (!mapFile.is_open())
{
- logger->log1("Unable to open extralayer.txt for writing");
+ reportAlways("Error opening file for writing: %s",
+ mapFileName.c_str());
return;
}