mirror of
https://github.com/apple/swift-system
synced 2026-11-29 05:24:25 +00:00
fixup: Move FileDescriptor.fileSize() to an internal extension in SystemTests
This commit is contained in:
1 parent
02daf4b6a7
commit
d90bf8529a
2 files changed
+25
-14
No files matched your search
@@ -122,18 +122,4 @@ extension FileDescriptor {
|
||||
return .success(buffer.count)
|
||||
}
|
||||
}
|
||||
|
||||
/// Return the current size of the file.
|
||||
///
|
||||
/// - Returns: The current size of the file, in bytes.
|
||||
@_alwaysEmitIntoClient
|
||||
@discardableResult
|
||||
public func fileSize(
|
||||
retryOnInterrupt: Bool = true
|
||||
) throws -> Int64 {
|
||||
let current = try seek(offset: 0, from: .current)
|
||||
let size = try seek(offset: 0, from: .end)
|
||||
try seek(offset: current, from: .start)
|
||||
return size
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
This source file is part of the Swift System open source project
|
||||
|
||||
Copyright (c) 2020 Apple Inc. and the Swift System project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
*/
|
||||
|
||||
#if SYSTEM_PACKAGE
|
||||
@testable import SystemPackage
|
||||
#else
|
||||
@testable import System
|
||||
#endif
|
||||
|
||||
extension FileDescriptor {
|
||||
internal func fileSize(
|
||||
retryOnInterrupt: Bool = true
|
||||
) throws -> Int64 {
|
||||
let current = try seek(offset: 0, from: .current)
|
||||
let size = try seek(offset: 0, from: .end)
|
||||
try seek(offset: current, from: .start)
|
||||
return size
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user