diff --git a/src/g_game.cpp b/src/g_game.cpp index b2e27eed4..f56bdac8e 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -2974,7 +2974,15 @@ bool G_CheckDemoStatus (void) formlen = demobuffer + 4; WriteLong (int(demo_p - demobuffer - 8), &formlen); - bool saved = M_WriteFile (demoname, demobuffer, int(demo_p - demobuffer)); + auto fw = FileWriter::Open(demoname); + bool saved = false; + if (fw != nullptr) + { + auto size = long(demo_p - demobuffer); + saved = fw->Write(demobuffer, size) == size; + delete fw; + if (!saved) remove(demoname); + } M_Free (demobuffer); demorecording = false; stoprecording = false; diff --git a/src/m_misc.cpp b/src/m_misc.cpp index 2b23ef6c2..21a0bfc74 100644 --- a/src/m_misc.cpp +++ b/src/m_misc.cpp @@ -88,32 +88,6 @@ EXTERN_CVAR(Bool, longsavemessages); static long ParseCommandLine (const char *args, int *argc, char **argv); -// -// M_WriteFile -// -#ifndef O_BINARY -#define O_BINARY 0 -#endif - -bool M_WriteFile (char const *name, void *source, int length) -{ - int handle; - int count; - - handle = open ( name, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666); - - if (handle == -1) - return false; - - count = write (handle, source, length); - close (handle); - - if (count < length) - return false; - - return true; -} - //--------------------------------------------------------------------------- // diff --git a/src/m_misc.h b/src/m_misc.h index 2eee63b7d..47db77bb7 100644 --- a/src/m_misc.h +++ b/src/m_misc.h @@ -33,7 +33,6 @@ class FIWadManager; extern FGameConfigFile *GameConfig; -bool M_WriteFile (char const *name, void *source, int length); void M_FindResponseFile (void); // [RH] M_ScreenShot now accepts a filename parameter.