Skip to content

Commit

Permalink
Changing OPFSGameFiles writeGameFilesData to use a sync access handle…
Browse files Browse the repository at this point in the history
… instead, so that it will work in Safari.
  • Loading branch information
lanceewing committed Apr 10, 2024
1 parent 59326b6 commit a226900
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions html/src/main/java/com/agifans/agile/gwt/OPFSGameFiles.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
Expand Down

0 comments on commit a226900

Please sign in to comment.