Skip to content

Commit 6430347

Browse files
committed
os: fix write_file
1 parent 07ee934 commit 6430347

3 files changed

Lines changed: 410 additions & 21 deletions

File tree

‎vlib/os/os.v‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -566,13 +566,11 @@ pub fn expand_tilde_to_home(path string) string {
566566
// write_file writes `text` data to a file with the given `path`.
567567
// If `path` already exists, it will be overwritten.
568568
pub fn write_file(path string, text string) ! {
569-
$if windows {
570-
mut f := create(path)!
571-
unsafe { f.write_full_buffer(text.str, usize(text.len))! }
569+
mut f := create(path)!
570+
defer {
572571
f.close()
573-
} $else {
574-
write_file_direct(path, text)!
575572
}
573+
unsafe { f.write_full_buffer(text.str, usize(text.len))! }
576574
}
577575

578576
pub struct ExecutableNotFoundError {

0 commit comments

Comments
 (0)