Skip to content

Commit

Permalink
fix: windows fopen mode should end with \x00
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Flash committed Feb 5, 2025
1 parent 6e0ca35 commit 18b74d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions fs_sync/fs_sync_native.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn get_error_message() -> String {

///|
fn read_file_to_bytes_internal(path : String) -> Bytes! {
let file = fopen_ffi(mbt_string_to_utf8_bytes(path, true), b"rb")
let file = fopen_ffi(mbt_string_to_utf8_bytes(path, true), b"rb\x00")
guard is_null(file) == 0 else { raise IOError(get_error_message()) }
guard fseek_ffi(file, 0, 2) == 0 else { raise IOError(get_error_message()) }
let size = ftell_ffi(file)
Expand Down Expand Up @@ -87,7 +87,7 @@ fn read_file_to_string_internal(

///|
fn write_bytes_to_file_internal(path : String, content : Bytes) -> Unit! {
let file = fopen_ffi(mbt_string_to_utf8_bytes(path, true), b"wb")
let file = fopen_ffi(mbt_string_to_utf8_bytes(path, true), b"wb\x00")
guard is_null(file) == 0 else { raise IOError(get_error_message()) }
let bytes_written = fwrite_ffi(content, 1, content.length(), file)
guard bytes_written == content.length() else {
Expand Down

0 comments on commit 18b74d7

Please sign in to comment.