diff --git a/Package.swift b/Package.swift index f63902b99..3d0914bab 100644 --- a/Package.swift +++ b/Package.swift @@ -17,7 +17,11 @@ import PackageDescription let swiftAtomics: PackageDescription.Target.Dependency = .product(name: "Atomics", package: "swift-atomics") let swiftCollections: PackageDescription.Target.Dependency = .product(name: "DequeModule", package: "swift-collections") -let swiftSystem: PackageDescription.Target.Dependency = .product(name: "SystemPackage", package: "swift-system") +let swiftSystem: PackageDescription.Target.Dependency = .product( + name: "SystemPackage", + package: "swift-system", + condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .linux, .android]) +) let package = Package( diff --git a/Sources/NIOFileSystem/BufferedReader.swift b/Sources/NIOFileSystem/BufferedReader.swift index 1fa2235b9..d50a9b62a 100644 --- a/Sources/NIOFileSystem/BufferedReader.swift +++ b/Sources/NIOFileSystem/BufferedReader.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import DequeModule import NIOCore @@ -206,3 +207,5 @@ extension ReadableFileHandleProtocol { return BufferedReader(wrapping: self, initialOffset: 0, capacity: Int(capacity.bytes)) } } + +#endif diff --git a/Sources/NIOFileSystem/BufferedWriter.swift b/Sources/NIOFileSystem/BufferedWriter.swift index cc1a70241..51753f5ec 100644 --- a/Sources/NIOFileSystem/BufferedWriter.swift +++ b/Sources/NIOFileSystem/BufferedWriter.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) + /// A writer which buffers bytes in memory before writing them to the file system. /// /// You can create a ``BufferedWriter`` by calling @@ -185,3 +187,5 @@ extension WritableFileHandleProtocol { ) } } + +#endif diff --git a/Sources/NIOFileSystem/ByteBuffer+FileSystem.swift b/Sources/NIOFileSystem/ByteBuffer+FileSystem.swift index 6c5be612e..4c3c394c4 100644 --- a/Sources/NIOFileSystem/ByteBuffer+FileSystem.swift +++ b/Sources/NIOFileSystem/ByteBuffer+FileSystem.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) @@ -95,3 +96,5 @@ extension ByteBuffer { ) } } + +#endif diff --git a/Sources/NIOFileSystem/ByteCount.swift b/Sources/NIOFileSystem/ByteCount.swift index 5ba29a0a4..05593ff9e 100644 --- a/Sources/NIOFileSystem/ByteCount.swift +++ b/Sources/NIOFileSystem/ByteCount.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) + /// Represents the number of bytes. public struct ByteCount: Hashable, Sendable { /// The number of bytes @@ -77,3 +79,5 @@ public struct ByteCount: Hashable, Sendable { return ByteCount(bytes: 1024 * 1024 * 1024 * count) } } + +#endif diff --git a/Sources/NIOFileSystem/Convenience.swift b/Sources/NIOFileSystem/Convenience.swift index 54f0a5644..e07f368b9 100644 --- a/Sources/NIOFileSystem/Convenience.swift +++ b/Sources/NIOFileSystem/Convenience.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage extension String { @@ -200,3 +201,5 @@ extension AsyncSequence where Self.Element == UInt8, Self: Sendable { ) } } + +#endif diff --git a/Sources/NIOFileSystem/DirectoryEntries.swift b/Sources/NIOFileSystem/DirectoryEntries.swift index 33c9275a0..3224da513 100644 --- a/Sources/NIOFileSystem/DirectoryEntries.swift +++ b/Sources/NIOFileSystem/DirectoryEntries.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import CNIODarwin import CNIOLinux import NIOConcurrencyHelpers @@ -652,3 +653,5 @@ extension UnsafeMutablePointer { return FilePath(platformString: self.pointee.fts_path) } } + +#endif diff --git a/Sources/NIOFileSystem/DirectoryEntry.swift b/Sources/NIOFileSystem/DirectoryEntry.swift index c6945eac7..2bb502110 100644 --- a/Sources/NIOFileSystem/DirectoryEntry.swift +++ b/Sources/NIOFileSystem/DirectoryEntry.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @preconcurrency import SystemPackage /// Information about an item within a directory. @@ -45,3 +46,5 @@ public struct DirectoryEntry: Sendable, Hashable, Equatable { self.type = type } } + +#endif diff --git a/Sources/NIOFileSystem/Exports.swift b/Sources/NIOFileSystem/Exports.swift index 2b73a5878..f7f0c244c 100644 --- a/Sources/NIOFileSystem/Exports.swift +++ b/Sources/NIOFileSystem/Exports.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) + // These types are used in our public API; expose them to make // life easier for users. @_exported import enum SystemPackage.CInterop @@ -19,3 +21,5 @@ @_exported import struct SystemPackage.FileDescriptor @_exported import struct SystemPackage.FilePath @_exported import struct SystemPackage.FilePermissions + +#endif diff --git a/Sources/NIOFileSystem/FileChunks.swift b/Sources/NIOFileSystem/FileChunks.swift index d8f4d9b94..9db55ce36 100644 --- a/Sources/NIOFileSystem/FileChunks.swift +++ b/Sources/NIOFileSystem/FileChunks.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOConcurrencyHelpers import NIOCore @preconcurrency import SystemPackage @@ -335,3 +336,5 @@ private struct ProducerState: Sendable { self.state = .done } } + +#endif diff --git a/Sources/NIOFileSystem/FileHandle.swift b/Sources/NIOFileSystem/FileHandle.swift index 1bf768242..a59436dc5 100644 --- a/Sources/NIOFileSystem/FileHandle.swift +++ b/Sources/NIOFileSystem/FileHandle.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) + import NIOCore /// Provides a ``FileHandle``. @@ -305,3 +307,5 @@ public struct DirectoryFileHandle: DirectoryFileHandleProtocol, _HasFileHandle { return DirectoryFileHandle(wrapping: systemFileHandle) } } + +#endif diff --git a/Sources/NIOFileSystem/FileHandleProtocol.swift b/Sources/NIOFileSystem/FileHandleProtocol.swift index 09463d354..1a8b2e495 100644 --- a/Sources/NIOFileSystem/FileHandleProtocol.swift +++ b/Sources/NIOFileSystem/FileHandleProtocol.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore import SystemPackage @@ -686,3 +687,4 @@ extension DirectoryFileHandleProtocol { } } } +#endif diff --git a/Sources/NIOFileSystem/FileInfo.swift b/Sources/NIOFileSystem/FileInfo.swift index ca362a4b7..6c8c2f1c8 100644 --- a/Sources/NIOFileSystem/FileInfo.swift +++ b/Sources/NIOFileSystem/FileInfo.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -248,3 +249,5 @@ extension FilePermissions { self = .init(rawValue: rawValue & ~S_IFMT) } } + +#endif diff --git a/Sources/NIOFileSystem/FileSystem.swift b/Sources/NIOFileSystem/FileSystem.swift index 9ba577d38..3fc7d5616 100644 --- a/Sources/NIOFileSystem/FileSystem.swift +++ b/Sources/NIOFileSystem/FileSystem.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) + import Atomics import NIOCore @preconcurrency import SystemPackage @@ -1435,3 +1437,5 @@ extension FileSystem { } } } + +#endif diff --git a/Sources/NIOFileSystem/FileSystemError+Syscall.swift b/Sources/NIOFileSystem/FileSystemError+Syscall.swift index df4c73ef9..5e18ae8ac 100644 --- a/Sources/NIOFileSystem/FileSystemError+Syscall.swift +++ b/Sources/NIOFileSystem/FileSystemError+Syscall.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -1026,3 +1027,5 @@ extension FileSystemError { ) } } + +#endif diff --git a/Sources/NIOFileSystem/FileSystemError.swift b/Sources/NIOFileSystem/FileSystemError.swift index 2ad674ebb..633db54f3 100644 --- a/Sources/NIOFileSystem/FileSystemError.swift +++ b/Sources/NIOFileSystem/FileSystemError.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage /// An error thrown as a result of interaction with the file system. @@ -331,3 +332,5 @@ extension FileSystemError { } } } + +#endif diff --git a/Sources/NIOFileSystem/FileSystemProtocol.swift b/Sources/NIOFileSystem/FileSystemProtocol.swift index 8c5111a2c..bd1ed6d18 100644 --- a/Sources/NIOFileSystem/FileSystemProtocol.swift +++ b/Sources/NIOFileSystem/FileSystemProtocol.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage /// The interface for interacting with a file system. @@ -476,3 +477,5 @@ extension FileSystemProtocol { ) } } + +#endif diff --git a/Sources/NIOFileSystem/FileType.swift b/Sources/NIOFileSystem/FileType.swift index 031a04ec0..1dc091008 100644 --- a/Sources/NIOFileSystem/FileType.swift +++ b/Sources/NIOFileSystem/FileType.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -167,3 +168,5 @@ extension FileType { } } } + +#endif diff --git a/Sources/NIOFileSystem/Internal/BufferedOrAnyStream.swift b/Sources/NIOFileSystem/Internal/BufferedOrAnyStream.swift index ed55ae18a..06a0ca54a 100644 --- a/Sources/NIOFileSystem/Internal/BufferedOrAnyStream.swift +++ b/Sources/NIOFileSystem/Internal/BufferedOrAnyStream.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) /// Wraps a ``BufferedStream`` or ``AnyAsyncSequence``. @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) internal enum BufferedOrAnyStream { @@ -88,3 +89,5 @@ internal struct AnyAsyncSequence: AsyncSequence { } } } + +#endif diff --git a/Sources/NIOFileSystem/Internal/BufferedStream.swift b/Sources/NIOFileSystem/Internal/BufferedStream.swift index 2c2605b36..a08173dd0 100644 --- a/Sources/NIOFileSystem/Internal/BufferedStream.swift +++ b/Sources/NIOFileSystem/Internal/BufferedStream.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import DequeModule import NIOConcurrencyHelpers @@ -1731,3 +1732,5 @@ extension BufferedStream { } } } + +#endif diff --git a/Sources/NIOFileSystem/Internal/Cancellation.swift b/Sources/NIOFileSystem/Internal/Cancellation.swift index b74b4d6b4..58dbf05df 100644 --- a/Sources/NIOFileSystem/Internal/Cancellation.swift +++ b/Sources/NIOFileSystem/Internal/Cancellation.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) + /// Executes the closure and masks cancellation. @_spi(Testing) @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) @@ -51,3 +53,5 @@ public func withUncancellableTearDown( try tearDownResult.get() return try result.get() } + +#endif diff --git a/Sources/NIOFileSystem/Internal/Concurrency Primitives/IOExecutor.swift b/Sources/NIOFileSystem/Internal/Concurrency Primitives/IOExecutor.swift index 45344c4bb..dccac6bb2 100644 --- a/Sources/NIOFileSystem/Internal/Concurrency Primitives/IOExecutor.swift +++ b/Sources/NIOFileSystem/Internal/Concurrency Primitives/IOExecutor.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import Atomics import DequeModule import Dispatch @@ -419,3 +420,4 @@ extension IOExecutor.Worker { } } } +#endif diff --git a/Sources/NIOFileSystem/Internal/Concurrency Primitives/Thread.swift b/Sources/NIOFileSystem/Internal/Concurrency Primitives/Thread.swift index d75841eb1..5e5eb58ab 100644 --- a/Sources/NIOFileSystem/Internal/Concurrency Primitives/Thread.swift +++ b/Sources/NIOFileSystem/Internal/Concurrency Primitives/Thread.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) #if os(Linux) || os(FreeBSD) || os(Android) import CNIOLinux #endif @@ -95,3 +96,4 @@ final class Thread { ThreadOpsSystem.run(handle: &handle, args: box, detachThread: detachThread) } } +#endif diff --git a/Sources/NIOFileSystem/Internal/Concurrency Primitives/ThreadPosix.swift b/Sources/NIOFileSystem/Internal/Concurrency Primitives/ThreadPosix.swift index 56a7c3e74..f3b06bc12 100644 --- a/Sources/NIOFileSystem/Internal/Concurrency Primitives/ThreadPosix.swift +++ b/Sources/NIOFileSystem/Internal/Concurrency Primitives/ThreadPosix.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) #if canImport(Glibc) || canImport(Musl) import CNIOLinux @@ -143,3 +144,4 @@ enum ThreadOpsPosix: ThreadOps { return pthread_equal(lhs, rhs) != 0 } } +#endif diff --git a/Sources/NIOFileSystem/Internal/Concurrency Primitives/UnsafeTransfer.swift b/Sources/NIOFileSystem/Internal/Concurrency Primitives/UnsafeTransfer.swift index c39dd0b5e..f6cf49d43 100644 --- a/Sources/NIOFileSystem/Internal/Concurrency Primitives/UnsafeTransfer.swift +++ b/Sources/NIOFileSystem/Internal/Concurrency Primitives/UnsafeTransfer.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @usableFromInline struct UnsafeTransfer: @unchecked Sendable { @usableFromInline @@ -22,3 +23,4 @@ struct UnsafeTransfer: @unchecked Sendable { self.wrappedValue = wrappedValue } } +#endif diff --git a/Sources/NIOFileSystem/Internal/String+UnsafeUnititializedCapacity.swift b/Sources/NIOFileSystem/Internal/String+UnsafeUnititializedCapacity.swift index 54c20a92a..5a9643843 100644 --- a/Sources/NIOFileSystem/Internal/String+UnsafeUnititializedCapacity.swift +++ b/Sources/NIOFileSystem/Internal/String+UnsafeUnititializedCapacity.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) + extension String { @inlinable init( @@ -59,3 +61,5 @@ extension String { } } } + +#endif diff --git a/Sources/NIOFileSystem/Internal/System Calls/CInterop.swift b/Sources/NIOFileSystem/Internal/System Calls/CInterop.swift index a8e512552..61304e0be 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/CInterop.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/CInterop.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -71,3 +72,4 @@ extension CInterop { typealias FTSPointer = UnsafeMutablePointer typealias FTSEntPointer = UnsafeMutablePointer } +#endif diff --git a/Sources/NIOFileSystem/Internal/System Calls/Errno.swift b/Sources/NIOFileSystem/Internal/System Calls/Errno.swift index 6637ee185..3d0eb0790 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/Errno.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/Errno.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -138,3 +139,4 @@ public func valueOrErrno( } } } +#endif diff --git a/Sources/NIOFileSystem/Internal/System Calls/FileDescriptor+Syscalls.swift b/Sources/NIOFileSystem/Internal/System Calls/FileDescriptor+Syscalls.swift index 3cfabc509..307e19478 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/FileDescriptor+Syscalls.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/FileDescriptor+Syscalls.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore import SystemPackage @@ -321,3 +322,4 @@ extension FileDescriptor { } } #endif +#endif diff --git a/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift b/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift index 679ecd8a7..264e4c92f 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/Mocking.swift @@ -21,6 +21,7 @@ See https://swift.org/LICENSE.txt for license information */ +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -365,3 +366,4 @@ internal func setTLS(_ key: _PlatformTLSKey, _ p: UnsafeMutableRawPointer?) { internal func getTLS(_ key: _PlatformTLSKey) -> UnsafeMutableRawPointer? { return pthread_getspecific(key) } +#endif diff --git a/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift b/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift index 423dd56bb..dcfd8ffde 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/Syscall.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -381,3 +382,4 @@ public enum Libc { } } } +#endif diff --git a/Sources/NIOFileSystem/Internal/System Calls/Syscalls.swift b/Sources/NIOFileSystem/Internal/System Calls/Syscalls.swift index be043e9de..332abf177 100644 --- a/Sources/NIOFileSystem/Internal/System Calls/Syscalls.swift +++ b/Sources/NIOFileSystem/Internal/System Calls/Syscalls.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage #if canImport(Darwin) @@ -415,3 +416,4 @@ internal func libc_fts_close( ) -> CInt { return fts_close(fts) } +#endif diff --git a/Sources/NIOFileSystem/Internal/SystemFileHandle.swift b/Sources/NIOFileSystem/Internal/SystemFileHandle.swift index 7ce2fb874..3dc518720 100644 --- a/Sources/NIOFileSystem/Internal/SystemFileHandle.swift +++ b/Sources/NIOFileSystem/Internal/SystemFileHandle.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOConcurrencyHelpers import NIOCore @preconcurrency import SystemPackage @@ -1303,3 +1304,5 @@ extension SystemFileHandle { } } } + +#endif diff --git a/Sources/NIOFileSystem/Internal/Utilities.swift b/Sources/NIOFileSystem/Internal/Utilities.swift index 9d6b94458..1f90b45d0 100644 --- a/Sources/NIOFileSystem/Internal/Utilities.swift +++ b/Sources/NIOFileSystem/Internal/Utilities.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage @usableFromInline @@ -43,3 +44,5 @@ extension Array where Element == UInt8 { return alphaNumericValues }() } + +#endif diff --git a/Sources/NIOFileSystem/OpenOptions.swift b/Sources/NIOFileSystem/OpenOptions.swift index 5dadc0bad..ce7ceaecc 100644 --- a/Sources/NIOFileSystem/OpenOptions.swift +++ b/Sources/NIOFileSystem/OpenOptions.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import SystemPackage /// Options for opening file handles. @@ -295,3 +296,5 @@ extension FilePermissions { .otherReadExecute, ] } + +#endif diff --git a/Sources/NIOFileSystemFoundationCompat/Date+FileInfo.swift b/Sources/NIOFileSystemFoundationCompat/Date+FileInfo.swift index 552401fb6..ada8aaa5f 100644 --- a/Sources/NIOFileSystemFoundationCompat/Date+FileInfo.swift +++ b/Sources/NIOFileSystemFoundationCompat/Date+FileInfo.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOFileSystem import struct Foundation.Date @@ -29,3 +30,4 @@ extension FileInfo.Timespec { return Date(timespec: self) } } +#endif diff --git a/Tests/NIOFileSystemFoundationCompatTests/FileSystemFoundationCompatTests.swift b/Tests/NIOFileSystemFoundationCompatTests/FileSystemFoundationCompatTests.swift index 4dcaba4f0..82ba73fd7 100644 --- a/Tests/NIOFileSystemFoundationCompatTests/FileSystemFoundationCompatTests.swift +++ b/Tests/NIOFileSystemFoundationCompatTests/FileSystemFoundationCompatTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOFileSystem import NIOFileSystemFoundationCompat import XCTest @@ -33,3 +34,4 @@ final class FileSystemBytesConformanceTests: XCTestCase { ) } } +#endif diff --git a/Tests/NIOFileSystemIntegrationTests/BufferedReaderTests.swift b/Tests/NIOFileSystemIntegrationTests/BufferedReaderTests.swift index ccf26350e..362aed212 100644 --- a/Tests/NIOFileSystemIntegrationTests/BufferedReaderTests.swift +++ b/Tests/NIOFileSystemIntegrationTests/BufferedReaderTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore import NIOFileSystem import XCTest @@ -259,3 +260,4 @@ final class BufferedReaderTests: XCTestCase { } } } +#endif diff --git a/Tests/NIOFileSystemIntegrationTests/BufferedWriterTests.swift b/Tests/NIOFileSystemIntegrationTests/BufferedWriterTests.swift index 68dad5290..cbd11840f 100644 --- a/Tests/NIOFileSystemIntegrationTests/BufferedWriterTests.swift +++ b/Tests/NIOFileSystemIntegrationTests/BufferedWriterTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore @_spi(Testing) import NIOFileSystem import XCTest @@ -141,3 +142,4 @@ final class BufferedWriterTests: XCTestCase { } } } +#endif diff --git a/Tests/NIOFileSystemIntegrationTests/ConvenienceTests.swift b/Tests/NIOFileSystemIntegrationTests/ConvenienceTests.swift index a1e533b89..2abab51b6 100644 --- a/Tests/NIOFileSystemIntegrationTests/ConvenienceTests.swift +++ b/Tests/NIOFileSystemIntegrationTests/ConvenienceTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore import NIOFileSystem import XCTest @@ -71,3 +72,4 @@ final class ConvenienceTests: XCTestCase { XCTAssertEqual(bytes, ByteBuffer(bytes: Array(0..<64))) } } +#endif diff --git a/Tests/NIOFileSystemIntegrationTests/FileHandleTests.swift b/Tests/NIOFileSystemIntegrationTests/FileHandleTests.swift index 6d2e13e5a..c18e2c8ec 100644 --- a/Tests/NIOFileSystemIntegrationTests/FileHandleTests.swift +++ b/Tests/NIOFileSystemIntegrationTests/FileHandleTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore @_spi(Testing) import NIOFileSystem import NIOFoundationCompat @@ -1104,3 +1105,4 @@ private func assertThrowsErrorClosed( XCTAssertEqual(error.code, .closed) } } +#endif diff --git a/Tests/NIOFileSystemIntegrationTests/FileSystemTests+SPI.swift b/Tests/NIOFileSystemIntegrationTests/FileSystemTests+SPI.swift index 0b6b5d74a..be4efcd89 100644 --- a/Tests/NIOFileSystemIntegrationTests/FileSystemTests+SPI.swift +++ b/Tests/NIOFileSystemIntegrationTests/FileSystemTests+SPI.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import SystemPackage import XCTest @@ -25,3 +26,4 @@ extension FileSystemTests { XCTAssertEqual(removed, 0) } } +#endif diff --git a/Tests/NIOFileSystemIntegrationTests/FileSystemTests.swift b/Tests/NIOFileSystemIntegrationTests/FileSystemTests.swift index 218ba491d..f24736a75 100644 --- a/Tests/NIOFileSystemIntegrationTests/FileSystemTests.swift +++ b/Tests/NIOFileSystemIntegrationTests/FileSystemTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore @_spi(Testing) import NIOFileSystem @preconcurrency import SystemPackage @@ -1429,3 +1430,4 @@ extension FileSystemTests { } } } +#endif diff --git a/Tests/NIOFileSystemIntegrationTests/XCTestExtensions.swift b/Tests/NIOFileSystemIntegrationTests/XCTestExtensions.swift index 9098c19ce..906defae0 100644 --- a/Tests/NIOFileSystemIntegrationTests/XCTestExtensions.swift +++ b/Tests/NIOFileSystemIntegrationTests/XCTestExtensions.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOFileSystem import XCTest @@ -68,3 +69,4 @@ func XCTAssertThrowsFileSystemErrorAsync( } } } +#endif diff --git a/Tests/NIOFileSystemTests/ByteCountTests.swift b/Tests/NIOFileSystemTests/ByteCountTests.swift index bb4146483..317c9d752 100644 --- a/Tests/NIOFileSystemTests/ByteCountTests.swift +++ b/Tests/NIOFileSystemTests/ByteCountTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOFileSystem import XCTest @@ -58,3 +59,4 @@ class ByteCountTests: XCTestCase { XCTAssertNotEqual(byteCount1, byteCount2) } } +#endif diff --git a/Tests/NIOFileSystemTests/DirectoryEntriesTests.swift b/Tests/NIOFileSystemTests/DirectoryEntriesTests.swift index 8f1532162..256c80dd3 100644 --- a/Tests/NIOFileSystemTests/DirectoryEntriesTests.swift +++ b/Tests/NIOFileSystemTests/DirectoryEntriesTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOFileSystem import XCTest @@ -70,3 +71,4 @@ final class DirectoryEntriesTests: XCTestCase { XCTAssertNil(end) } } +#endif diff --git a/Tests/NIOFileSystemTests/FileChunksTests.swift b/Tests/NIOFileSystemTests/FileChunksTests.swift index ba6f4b931..c83e50869 100644 --- a/Tests/NIOFileSystemTests/FileChunksTests.swift +++ b/Tests/NIOFileSystemTests/FileChunksTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOCore import NIOFileSystem import XCTest @@ -38,3 +39,4 @@ final class FileChunksTests: XCTestCase { XCTAssertNil(end) } } +#endif diff --git a/Tests/NIOFileSystemTests/FileHandleTests.swift b/Tests/NIOFileSystemTests/FileHandleTests.swift index 58e6594b7..094727915 100644 --- a/Tests/NIOFileSystemTests/FileHandleTests.swift +++ b/Tests/NIOFileSystemTests/FileHandleTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import XCTest @@ -269,3 +270,4 @@ extension MockingDriver { } } #endif +#endif diff --git a/Tests/NIOFileSystemTests/FileInfoTests.swift b/Tests/NIOFileSystemTests/FileInfoTests.swift index b26dcaf54..c6b9760a4 100644 --- a/Tests/NIOFileSystemTests/FileInfoTests.swift +++ b/Tests/NIOFileSystemTests/FileInfoTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOFileSystem import XCTest @@ -156,3 +157,4 @@ final class FileInfoTests: XCTestCase { #endif } } +#endif diff --git a/Tests/NIOFileSystemTests/FileOpenOptionsTests.swift b/Tests/NIOFileSystemTests/FileOpenOptionsTests.swift index 9f82e85c3..6c7525e67 100644 --- a/Tests/NIOFileSystemTests/FileOpenOptionsTests.swift +++ b/Tests/NIOFileSystemTests/FileOpenOptionsTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import XCTest @@ -98,3 +99,4 @@ final class FileOpenOptionsTests: XCTestCase { XCTAssertEqual(FileDescriptor.OpenOptions(options), [.create, .exclusiveCreate, .noFollow]) } } +#endif diff --git a/Tests/NIOFileSystemTests/FileSystemErrorTests.swift b/Tests/NIOFileSystemTests/FileSystemErrorTests.swift index 68aaaab34..b86ac6488 100644 --- a/Tests/NIOFileSystemTests/FileSystemErrorTests.swift +++ b/Tests/NIOFileSystemTests/FileSystemErrorTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import XCTest @@ -608,3 +609,4 @@ private func assertCauseIsSyscall( extension FileSystemError.SourceLocation { fileprivate static let fixed = Self(function: "fn", file: "file", line: 1) } +#endif diff --git a/Tests/NIOFileSystemTests/FileTypeTests.swift b/Tests/NIOFileSystemTests/FileTypeTests.swift index 179079d8f..2fea3cd46 100644 --- a/Tests/NIOFileSystemTests/FileTypeTests.swift +++ b/Tests/NIOFileSystemTests/FileTypeTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import XCTest @@ -79,3 +80,4 @@ final class FileTypeTests: XCTestCase { #endif } } +#endif diff --git a/Tests/NIOFileSystemTests/Internal/CancellationTests.swift b/Tests/NIOFileSystemTests/Internal/CancellationTests.swift index d89c81e80..e0b658c20 100644 --- a/Tests/NIOFileSystemTests/Internal/CancellationTests.swift +++ b/Tests/NIOFileSystemTests/Internal/CancellationTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import Atomics @_spi(Testing) import NIOFileSystem import XCTest @@ -87,3 +88,4 @@ final class CancellationTests: XCTestCase { } } } +#endif diff --git a/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/BufferedStreamTests.swift b/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/BufferedStreamTests.swift index a02a63e3d..efca5f312 100644 --- a/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/BufferedStreamTests.swift +++ b/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/BufferedStreamTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import XCTest @testable import NIOFileSystem @@ -1139,3 +1140,4 @@ extension AsyncThrowingStream { return (stream, continuation!) } } +#endif diff --git a/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/IOExecutorTests.swift b/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/IOExecutorTests.swift index 137b6c2c3..ec6111bdd 100644 --- a/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/IOExecutorTests.swift +++ b/Tests/NIOFileSystemTests/Internal/Concurrency Primitives/IOExecutorTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import XCTest @@ -172,3 +173,4 @@ private func withExecutor( await executor.drain() } } +#endif diff --git a/Tests/NIOFileSystemTests/Internal/MockingInfrastructure.swift b/Tests/NIOFileSystemTests/Internal/MockingInfrastructure.swift index 9ecdf7b75..8c58bea50 100644 --- a/Tests/NIOFileSystemTests/Internal/MockingInfrastructure.swift +++ b/Tests/NIOFileSystemTests/Internal/MockingInfrastructure.swift @@ -21,6 +21,7 @@ See https://swift.org/LICENSE.txt for license information */ +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import SystemPackage import XCTest @@ -254,3 +255,4 @@ internal func withWindowsPaths(enabled: Bool, _ body: () -> Void) { _withWindowsPaths(enabled: enabled, body) } #endif +#endif diff --git a/Tests/NIOFileSystemTests/Internal/SyscallTests.swift b/Tests/NIOFileSystemTests/Internal/SyscallTests.swift index b87c42c58..63fc8fe1f 100644 --- a/Tests/NIOFileSystemTests/Internal/SyscallTests.swift +++ b/Tests/NIOFileSystemTests/Internal/SyscallTests.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) @_spi(Testing) import NIOFileSystem import SystemPackage import XCTest @@ -470,3 +471,4 @@ extension Array where Element == MockTestCase { } } #endif +#endif diff --git a/Tests/NIOFileSystemTests/XCTestExtensions.swift b/Tests/NIOFileSystemTests/XCTestExtensions.swift index 4b952cd03..5ed4d026d 100644 --- a/Tests/NIOFileSystemTests/XCTestExtensions.swift +++ b/Tests/NIOFileSystemTests/XCTestExtensions.swift @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) || os(Linux) || os(Android) import NIOFileSystem import XCTest @@ -67,3 +68,4 @@ func XCTAssertSystemCallError( XCTAssertEqual(systemCallError.systemCall, name, file: file, line: line) XCTAssertEqual(systemCallError.errno, errno, file: file, line: line) } +#endif diff --git a/Tests/NIOPosixTests/SocketOptionProviderTest.swift b/Tests/NIOPosixTests/SocketOptionProviderTest.swift index 439792e47..73de84879 100644 --- a/Tests/NIOPosixTests/SocketOptionProviderTest.swift +++ b/Tests/NIOPosixTests/SocketOptionProviderTest.swift @@ -290,6 +290,8 @@ final class SocketOptionProviderTest: XCTestCase { // We just need to soundness check something here to ensure that the data is vaguely reasonable. XCTAssertEqual(tcpConnectionInfo.tcpi_state, UInt8(TSI_S_ESTABLISHED)) #endif + // Suppress the unused warning + _ = tcpConnectionInfo #endif } }