src/demo.cpp

changeset 15
3d3e5f0fc4cc
parent 13
9bdddd2ccde6
child 17
b41d74bacdea
--- a/src/demo.cpp	Sun Aug 11 03:08:14 2013 +0300
+++ b/src/demo.cpp	Sun Aug 11 03:47:58 2013 +0300
@@ -38,7 +38,12 @@
 		if (skip-- > 0)
 			continue;
 		
-		if (c.toAscii() == '\034') {
+#if (QT_VERSION >= QT_VERSION_CHECK (5, 0, 0))
+		if (c.toLatin1() == '\034')
+#else
+		if (c.toAscii() == '\034')
+#endif // QT_VERSION
+		{
 			skip = 1;
 			continue;
 		}
@@ -101,8 +106,14 @@
 
 // =============================================================================
 // -----------------------------------------------------------------------------
+#ifdef _WIN32
+# define FILE_FLAGS "rb"
+#else
+# define FILE_FLAGS "r"
+#endif // _WIN32
+
 int launchDemo (str path) {
-	FILE* fp = fopen (path.toStdString().c_str(), "r");
+	FILE* fp = fopen (path.toStdString().c_str(), FILE_FLAGS);
 	
 	if (!fp) {
 		error (fmt (tr ("Couldn't open '%1' for reading: %2"), path, strerror (errno)));
@@ -115,8 +126,9 @@
 	
 	char* buf = new char[fsize];
 	
-	if (fread (buf, 1, fsize, fp) != fsize) {
-		error (tr ("I/O error"));
+	const size_t bytesRead = fread (buf, 1, fsize, fp);
+	if (bytesRead != fsize) {
+		error (fmt (tr ("I/O error: %1 / %2 bytes read"), bytesRead, fsize));
 		delete[] buf;
 		return 2;
 	}

mercurial