From 559cbaade8faaf9a0056da84069ddc9cb96faae3 Mon Sep 17 00:00:00 2001 From: Yue Huang <806628409@qq.com> Date: Mon, 16 Sep 2024 00:09:51 +0800 Subject: [PATCH] Update recording_tools.py --- src/spikeinterface/core/recording_tools.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/spikeinterface/core/recording_tools.py b/src/spikeinterface/core/recording_tools.py index f649e60b28..8f42774dec 100644 --- a/src/spikeinterface/core/recording_tools.py +++ b/src/spikeinterface/core/recording_tools.py @@ -131,14 +131,13 @@ def write_binary_recording( data_size_bytes = dtype_size_bytes * num_frames * num_channels file_size_bytes = data_size_bytes + byte_offset - # create a file with file_size_bytes + # Create an empty file with file_size_bytes file = open(file_path, "wb+") - if platform.system() == "Windows": - file.seek(file_size_bytes - 1) - file.write(b"\0") - else: - file.truncate(file_size_bytes) + + # The previous implementation `file.truncate(file_size_bytes)` was slow on Windows (#3408) + file.seek(file_size_bytes - 1) file.write(b"\0") + file.close() assert Path(file_path).is_file()