[TAR] Simplify TarWriter.finalize

This is possible since the write function already performs the synchronization the file handle.
This commit is contained in:
Timofey Solomko
2022-01-22 13:38:32 +03:00
parent f9f5e9e613
commit ba7e4448d1
+2 -9
View File
@@ -73,20 +73,13 @@ public struct TarWriter {
public func finalize() throws {
// First, we append two 512-byte blocks consisting of zeros as an EOF marker.
try write(Data(count: 1024))
#if compiler(<5.2)
handle.synchronizeFile()
#else
if #available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *) {
try handle.synchronize()
} else {
handle.synchronizeFile()
}
#endif
// The synchronization is performed by the write(_:) function automatically.
}
private func write(_ data: Data) throws {
#if compiler(<5.2)
handle.write(data)
handle.synchronizeFile()
#else
if #available(macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4, *) {
try handle.write(contentsOf: data)