From a226900f0da068b51ddd471ee8fdb6b67983fd2f Mon Sep 17 00:00:00 2001 From: Lance Ewing Date: Wed, 10 Apr 2024 17:40:29 +0100 Subject: [PATCH] Changing OPFSGameFiles writeGameFilesData to use a sync access handle instead, so that it will work in Safari. --- .../main/java/com/agifans/agile/gwt/OPFSGameFiles.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/html/src/main/java/com/agifans/agile/gwt/OPFSGameFiles.java b/html/src/main/java/com/agifans/agile/gwt/OPFSGameFiles.java index 1daeb0b..3f1b336 100644 --- a/html/src/main/java/com/agifans/agile/gwt/OPFSGameFiles.java +++ b/html/src/main/java/com/agifans/agile/gwt/OPFSGameFiles.java @@ -24,12 +24,12 @@ public final native void writeGameFilesData(String gameDirectoryName, ArrayBuffe // Create an OPFS sub-directory and data file for this game. gameFilesDir.getDirectoryHandle(gameDirectoryName, {create: true}).then(function(gameDir) { gameDir.getFileHandle('GAMEFILES.DAT', {create: true}).then(function(gameDataFileHandle) { - // Open a writable stream for the file. - gameDataFileHandle.createWritable().then(function(gameDataFileStream) { + // Create a sync access handle for the file (supported in Safari) + gameDataFileHandle.createSyncAccessHandle().then(function(gameDataSyncAccessHandle) { // Write the game data out and then close. - gameDataFileStream.write(gameDataArrayBuffer).then(function() { - gameDataFileStream.close() - }); + gameDataSyncAccessHandle.write(gameDataArrayBuffer); + gameDataSyncAccessHandle.flush(); + gameDataSyncAccessHandle.close(); }); }); });