Skip to content

Commit

Permalink
Update recording_tools.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jiumao2 committed Sep 15, 2024
1 parent d460c1e commit 559cbaa
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/spikeinterface/core/recording_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 559cbaa

Please sign in to comment.