Skip to content

Commit 0a55564

Browse files
dannys42Danny Sung
and
Danny Sung
authored
Fix to append rather than overwrite data in existing files (#184)
* Fix to append rather than overwrite data in existing files * Update #availability flag for all supported platforms Co-authored-by: Danny Sung <[email protected]>
1 parent a1965f8 commit 0a55564

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/Segment/Utilities/OutputFileStream.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ internal class OutputFileStream {
5353
if fileHandle != nil { return }
5454
do {
5555
fileHandle = try FileHandle(forWritingTo: fileURL)
56+
if #available(iOS 13.4, macOS 10.15.4, tvOS 13.4, *) {
57+
_ = try? fileHandle?.seekToEnd()
58+
} else if #available(tvOS 13.0, *) {
59+
try? fileHandle?.seek(toOffset: .max)
60+
} else {
61+
// unsupported
62+
throw OutputStreamError.unableToOpen(fileURL.path)
63+
}
5664
} catch {
5765
throw OutputStreamError.unableToOpen(fileURL.path)
5866
}

0 commit comments

Comments
 (0)