Skip to content

Commit

Permalink
Use most up-to-date FileHandle APIs (#74)
Browse files Browse the repository at this point in the history
* Use most up-to-date FileHandle APIs

* Ignore FileHandleExtensions.swift
  • Loading branch information
dfed authored Nov 10, 2022
1 parent 26a1c97 commit 61f099f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Sources/CacheAdvance/FileHandleExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ extension FileHandle {

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

/// A method to write data to a file handle that is safe to call in Swift from any operation system version.
func write(data: Data) throws {
if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) {
if #available(iOS 13.4, tvOS 13.4, watchOS 6.2, macOS 10.15.4, *) {
return try write(contentsOf: data)
} else if #available(iOS 13.0, tvOS 13.0, watchOS 6.0, macOS 10.15, *) {
return try __write(data, error: ())
} else {
return try ObjectiveC.unsafe { write(data) }
Expand Down
4 changes: 4 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,9 @@ coverage:
patch: off

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

0 comments on commit 61f099f

Please sign in to comment.