Skip to content
This repository was archived by the owner on Dec 15, 2024. It is now read-only.

Commit bd8b7a5

Browse files
authored
Merge pull request #39 from lvscar/fix_file-write
make file manager set function truncate opened file at first
2 parents 3b75475 + e7e0382 commit bd8b7a5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/SwiftFoundation/FileManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public struct FileManager {
212212
public static func set(contents data: Data, at path: String) throws {
213213

214214
// get file descriptor for path (open file)
215-
let file = open(path, O_WRONLY)
215+
let file = open(path, O_TRUNC | O_WRONLY)
216216

217217
guard file != -1 else { throw POSIXError.fromErrno! }
218218

0 commit comments

Comments
 (0)