Skip to content

Commit

Permalink
make throwingGlobalErrno public
Browse files Browse the repository at this point in the history
  • Loading branch information
lhoward committed May 17, 2024
1 parent eaf38a4 commit 9bc1668
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Sources/IORingUtils/Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ public extension FileDescriptorRepresentable {
func getSize() throws -> Int {
var st = stat()

if fstat(fileDescriptor, &st) < 0 {
throw Errno.lastError
throwingGlobalErrno {
fstat(fileDescriptor, &st)
}

if st.st_mode & S_IFMT == S_IFREG {
Expand All @@ -145,10 +145,10 @@ extension Errno {
static var lastError: Errno { Errno(rawValue: errno) }

@discardableResult
static func throwingGlobalErrno(_ body: @escaping () -> CInt) throws -> CInt {
public static func throwingGlobalErrno(_ body: @escaping () -> CInt) throws -> CInt {
let result = body()
if result < 0 {
throw Errno(rawValue: errno)
throw Errno.lastError
}
return result
}
Expand Down

0 comments on commit 9bc1668

Please sign in to comment.