Skip to content

Commit 61f099f

Browse files
authored
Use most up-to-date FileHandle APIs (#74)
* Use most up-to-date FileHandle APIs * Ignore FileHandleExtensions.swift
1 parent 26a1c97 commit 61f099f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Sources/CacheAdvance/FileHandleExtensions.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,13 @@ extension FileHandle {
2323

2424
/// A method to read data from a file handle that is safe to call in Swift from any operation system version.
2525
func readDataUp(toLength length: Int) throws -> Data {
26-
if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) {
26+
if #available(iOS 13.4, tvOS 13.4, watchOS 6.2, macOS 10.15.4, *) {
27+
if let data = try read(upToCount: length) {
28+
return data
29+
} else {
30+
return Data()
31+
}
32+
} else if #available(iOS 13.0, tvOS 13.0, watchOS 6.2, macOS 10.15, *) {
2733
return try __readDataUp(toLength: length)
2834
} else {
2935
return try ObjectiveC.unsafe { readData(ofLength: length) }
@@ -32,7 +38,9 @@ extension FileHandle {
3238

3339
/// A method to write data to a file handle that is safe to call in Swift from any operation system version.
3440
func write(data: Data) throws {
35-
if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) {
41+
if #available(iOS 13.4, tvOS 13.4, watchOS 6.2, macOS 10.15.4, *) {
42+
return try write(contentsOf: data)
43+
} else if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) {
3644
return try __write(data, error: ())
3745
} else {
3846
return try ObjectiveC.unsafe { write(data) }

codecov.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,9 @@ coverage:
1414
patch: off
1515

1616
ignore:
17+
# Due to limitations in Github Actions' supported Xcode versions, we can't get good coverage on this file.
18+
- "Sources/CacheAdvance/FileHandleExtensions.swift"
19+
# This package is not shipped and only includes testing helpers.
1720
- "Sources/LorumIpsum"
21+
# This package is not shipped.
1822
- "Tests"

0 commit comments

Comments
 (0)