mirror of
https://github.com/apple/swift-system
synced 2026-11-29 05:24:25 +00:00
Unbreak the Windows port
This commit is contained in:
1 parent
5c18991f29
commit
147ebc053a
3 files changed
+16
-12
No files matched your search
@@ -372,9 +372,9 @@ extension FileDescriptor {
|
||||
}
|
||||
}
|
||||
|
||||
#if !os(Windows)
|
||||
/*System 1.1.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
|
||||
extension FileDescriptor {
|
||||
#if !os(Windows)
|
||||
/// Create a pipe, a unidirectional data channel which can be used for interprocess communication.
|
||||
///
|
||||
/// - Returns: The pair of file descriptors.
|
||||
@@ -396,12 +396,12 @@ extension FileDescriptor {
|
||||
}
|
||||
}.map { _ in (.init(rawValue: fds.0), .init(rawValue: fds.1)) }
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(Windows)
|
||||
/*System 1.2.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
|
||||
extension FileDescriptor {
|
||||
#if !os(Windows)
|
||||
/// Truncate or extend the file referenced by this file descriptor.
|
||||
///
|
||||
/// - Parameters:
|
||||
@@ -444,5 +444,5 @@ extension FileDescriptor {
|
||||
system_ftruncate(self.rawValue, _COffT(newSize))
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
@@ -52,14 +52,6 @@ internal func system_close(_ fd: Int32) -> Int32 {
|
||||
return close(fd)
|
||||
}
|
||||
|
||||
// truncate
|
||||
internal func system_ftruncate(_ fd: Int32, _ length: off_t) -> Int32 {
|
||||
#if ENABLE_MOCKING
|
||||
if mockingEnabled { return _mock(fd, length) }
|
||||
#endif
|
||||
return ftruncate(fd, length)
|
||||
}
|
||||
|
||||
// read
|
||||
internal func system_read(
|
||||
_ fd: Int32, _ buf: UnsafeMutableRawPointer!, _ nbyte: Int
|
||||
@@ -123,6 +115,7 @@ internal func system_dup2(_ fd: Int32, _ fd2: Int32) -> Int32 {
|
||||
#endif
|
||||
return dup2(fd, fd2)
|
||||
}
|
||||
|
||||
#if !os(Windows)
|
||||
internal func system_pipe(_ fds: UnsafeMutablePointer<Int32>) -> CInt {
|
||||
#if ENABLE_MOCKING
|
||||
@@ -131,3 +124,12 @@ internal func system_pipe(_ fds: UnsafeMutablePointer<Int32>) -> CInt {
|
||||
return pipe(fds)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !os(Windows)
|
||||
internal func system_ftruncate(_ fd: Int32, _ length: off_t) -> Int32 {
|
||||
#if ENABLE_MOCKING
|
||||
if mockingEnabled { return _mock(fd, length) }
|
||||
#endif
|
||||
return ftruncate(fd, length)
|
||||
}
|
||||
#endif
|
||||
@@ -82,9 +82,11 @@ final class FileOperationsTest: XCTestCase {
|
||||
retryOnInterrupt: retryOnInterrupt)
|
||||
},
|
||||
|
||||
#if !os(Windows)
|
||||
MockTestCase(name: "ftruncate", .interruptable, rawFD, 42) { retryOnInterrupt in
|
||||
_ = try fd.resize(to: 42, retryOnInterrupt: retryOnInterrupt)
|
||||
},
|
||||
#endif
|
||||
]
|
||||
|
||||
for test in syscallTestCases { test.runAllTests() }
|
||||
|
||||
Reference in new issue
Block a user