Skip to content

Commit 82a6704

Browse files
authored
Merge pull request #88 from apple/lorentey/unbroke-windows
Unbreak the Windows port
2 parents 5c18991 + bd5a7bb commit 82a6704

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

Sources/System/FileOperations.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ extension FileDescriptor {
372372
}
373373
}
374374

375+
#if !os(Windows)
375376
/*System 1.1.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
376377
extension FileDescriptor {
377-
#if !os(Windows)
378378
/// Create a pipe, a unidirectional data channel which can be used for interprocess communication.
379379
///
380380
/// - Returns: The pair of file descriptors.
@@ -396,12 +396,12 @@ extension FileDescriptor {
396396
}
397397
}.map { _ in (.init(rawValue: fds.0), .init(rawValue: fds.1)) }
398398
}
399-
#endif
400399
}
400+
#endif
401401

402+
#if !os(Windows)
402403
/*System 1.2.0, @available(macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, *)*/
403404
extension FileDescriptor {
404-
#if !os(Windows)
405405
/// Truncate or extend the file referenced by this file descriptor.
406406
///
407407
/// - Parameters:
@@ -444,5 +444,5 @@ extension FileDescriptor {
444444
system_ftruncate(self.rawValue, _COffT(newSize))
445445
}
446446
}
447-
#endif
448447
}
448+
#endif

Sources/System/Internals/Syscalls.swift

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,6 @@ internal func system_close(_ fd: Int32) -> Int32 {
5252
return close(fd)
5353
}
5454

55-
// truncate
56-
internal func system_ftruncate(_ fd: Int32, _ length: off_t) -> Int32 {
57-
#if ENABLE_MOCKING
58-
if mockingEnabled { return _mock(fd, length) }
59-
#endif
60-
return ftruncate(fd, length)
61-
}
62-
6355
// read
6456
internal func system_read(
6557
_ fd: Int32, _ buf: UnsafeMutableRawPointer!, _ nbyte: Int
@@ -123,6 +115,7 @@ internal func system_dup2(_ fd: Int32, _ fd2: Int32) -> Int32 {
123115
#endif
124116
return dup2(fd, fd2)
125117
}
118+
126119
#if !os(Windows)
127120
internal func system_pipe(_ fds: UnsafeMutablePointer<Int32>) -> CInt {
128121
#if ENABLE_MOCKING
@@ -131,3 +124,12 @@ internal func system_pipe(_ fds: UnsafeMutablePointer<Int32>) -> CInt {
131124
return pipe(fds)
132125
}
133126
#endif
127+
128+
#if !os(Windows)
129+
internal func system_ftruncate(_ fd: Int32, _ length: off_t) -> Int32 {
130+
#if ENABLE_MOCKING
131+
if mockingEnabled { return _mock(fd, length) }
132+
#endif
133+
return ftruncate(fd, length)
134+
}
135+
#endif

Tests/SystemTests/FileOperationsTest.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ final class FileOperationsTest: XCTestCase {
8181
_ = try fd.duplicate(as: FileDescriptor(rawValue: 42),
8282
retryOnInterrupt: retryOnInterrupt)
8383
},
84-
85-
MockTestCase(name: "ftruncate", .interruptable, rawFD, 42) { retryOnInterrupt in
86-
_ = try fd.resize(to: 42, retryOnInterrupt: retryOnInterrupt)
87-
},
8884
]
8985

9086
for test in syscallTestCases { test.runAllTests() }

0 commit comments

Comments
 (0)