summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 23:25:16 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 23:25:16 +0100
commitfad90081d2c039a2c34badf16ba48e0ae80bc014 (patch)
tree96a93dd67176ed8e1e4c61492b6e5915eb65f020
parentFixed a crash bug (diff)
downloadcuberite-fad90081d2c039a2c34badf16ba48e0ae80bc014.tar
cuberite-fad90081d2c039a2c34badf16ba48e0ae80bc014.tar.gz
cuberite-fad90081d2c039a2c34badf16ba48e0ae80bc014.tar.bz2
cuberite-fad90081d2c039a2c34badf16ba48e0ae80bc014.tar.lz
cuberite-fad90081d2c039a2c34badf16ba48e0ae80bc014.tar.xz
cuberite-fad90081d2c039a2c34badf16ba48e0ae80bc014.tar.zst
cuberite-fad90081d2c039a2c34badf16ba48e0ae80bc014.zip
-rw-r--r--src/OSSupport/File.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/OSSupport/File.cpp b/src/OSSupport/File.cpp
index 0ebd04915..17070030f 100644
--- a/src/OSSupport/File.cpp
+++ b/src/OSSupport/File.cpp
@@ -73,14 +73,26 @@ bool cFile::Open(const AString & iFileName, eMode iMode)
return false;
}
}
- m_File = fopen( (FILE_IO_PREFIX + iFileName).c_str(), Mode);
+
+#ifdef _WIN32
+ fopen_s(&m_File, (FILE_IO_PREFIX + iFileName).c_str(), Mode);
+#else
+ m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), Mode);
+#endif // _WIN32
+
if ((m_File == NULL) && (iMode == fmReadWrite))
{
// Fix for MS not following C spec, opening "a" mode files for writing at the end only
// The file open operation has been tried with "read update", fails if file not found
// So now we know either the file doesn't exist or we don't have rights, no need to worry about file contents.
// Simply re-open for read-writing, erasing existing contents:
- m_File = fopen( (FILE_IO_PREFIX + iFileName).c_str(), "wb+");
+
+#ifdef _WIN32
+ fopen_s(&m_File, (FILE_IO_PREFIX + iFileName).c_str(), "wb+");
+#else
+ m_File = fopen((FILE_IO_PREFIX + iFileName).c_str(), "wb+");
+#endif // _WIN32
+
}
return (m_File != NULL);
}