[Scummvm-git-logs] scummvm master -> 0c60d296946b6b0c321ae83e76b915a29984554d

lephilousophe noreply at scummvm.org
Thu Oct 3 06:37:24 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
0c60d29694 Revert "BACKENDS: FS: Make file writing atomic"


Commit: 0c60d296946b6b0c321ae83e76b915a29984554d
    https://github.com/scummvm/scummvm/commit/0c60d296946b6b0c321ae83e76b915a29984554d
Author: Le Philousophe (lephilousophe at users.noreply.github.com)
Date: 2024-10-03T08:35:57+02:00

Commit Message:
Revert "BACKENDS: FS: Make file writing atomic"

This reverts commit 99dc7641a998cc26fa2aa6eaf0c55f22f4722e33.
This causes bug #15392, a build failure on Dreamcast and changes too
much the semantics.
A better approach will need to be found, especially for streaming files
like logs.

Changed paths:
    backends/fs/stdiostream.cpp
    backends/fs/stdiostream.h
    backends/log/log.cpp


diff --git a/backends/fs/stdiostream.cpp b/backends/fs/stdiostream.cpp
index 5c5c5a26ea7..f6b58e23ff5 100644
--- a/backends/fs/stdiostream.cpp
+++ b/backends/fs/stdiostream.cpp
@@ -33,26 +33,13 @@
 
 // Include this after windows.h so we don't get a warning for redefining ARRAYSIZE
 #include "backends/fs/stdiostream.h"
-#include "common/textconsole.h"
 
-StdioStream::StdioStream(void *handle) : _handle(handle), _path(nullptr) {
+StdioStream::StdioStream(void *handle) : _handle(handle) {
 	assert(handle);
 }
 
 StdioStream::~StdioStream() {
 	fclose((FILE *)_handle);
-
-	if (!_path) {
-		return;
-	}
-
-	Common::String tmpPath(*_path);
-	tmpPath += ".tmp";
-	if (rename(tmpPath.c_str(), _path->c_str())) {
-		warning("Couldn't save file %s", _path->c_str());
-	}
-
-	delete _path;
 }
 
 bool StdioStream::err() const {
@@ -139,30 +126,19 @@ bool StdioStream::flush() {
 
 StdioStream *StdioStream::makeFromPathHelper(const Common::String &path, bool writeMode,
 		StdioStream *(*factory)(void *handle)) {
-	Common::String tmpPath(path);
-	if (writeMode) {
-		tmpPath += ".tmp";
-	}
 #if defined(WIN32) && defined(UNICODE)
-	wchar_t *wPath = Win32::stringToTchar(tmpPath);
+	wchar_t *wPath = Win32::stringToTchar(path);
 	FILE *handle = _wfopen(wPath, writeMode ? L"wb" : L"rb");
 	free(wPath);
 #elif defined(HAS_FOPEN64)
-	FILE *handle = fopen64(tmpPath.c_str(), writeMode ? "wb" : "rb");
+	FILE *handle = fopen64(path.c_str(), writeMode ? "wb" : "rb");
 #else
-	FILE *handle = fopen(tmpPath.c_str(), writeMode ? "wb" : "rb");
+	FILE *handle = fopen(path.c_str(), writeMode ? "wb" : "rb");
 #endif
 
-	if (!handle) {
-		return nullptr;
-	}
-
-	StdioStream *stream = factory(handle);
-	if (writeMode) {
-		stream->_path = new Common::String(path);
-	}
-
-	return stream;
+	if (handle)
+		return new factory(handle);
+	return nullptr;
 }
 
 #endif
diff --git a/backends/fs/stdiostream.h b/backends/fs/stdiostream.h
index ef17c5cc0fe..c6856260b88 100644
--- a/backends/fs/stdiostream.h
+++ b/backends/fs/stdiostream.h
@@ -31,7 +31,6 @@ class StdioStream : public Common::SeekableReadStream, public Common::SeekableWr
 protected:
 	/** File handle to the actual file. */
 	void *_handle;
-	Common::String *_path;
 
 	static StdioStream *makeFromPathHelper(const Common::String &path, bool writeMode,
 			StdioStream *(*factory)(void *handle));
diff --git a/backends/log/log.cpp b/backends/log/log.cpp
index 44271232b89..dc98dcb2f17 100644
--- a/backends/log/log.cpp
+++ b/backends/log/log.cpp
@@ -56,11 +56,8 @@ void Log::close() {
 		// Output a message to indicate that the log was closed successfully
 		print("--- Log closed successfully.\n");
 
-		// This avoids a segfault if a warning is issued when deleting the stream
-		Common::WriteStream *stream = _stream;
+		delete _stream;
 		_stream = nullptr;
-
-		delete stream;
 	}
 }
 




More information about the Scummvm-git-logs mailing list