Skip to content

Commit 1972782

Browse files
[wasm] Make Data.write(to:options:) API surface available on WASI
But its implementation will throw an error if called.
1 parent ba532b0 commit 1972782

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Sources/Foundation/Data.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -2314,13 +2314,15 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
23142314
}
23152315
#endif
23162316

2317-
#if !os(WASI)
23182317
/// Write the contents of the `Data` to a location.
23192318
///
23202319
/// - parameter url: The location to write the data into.
23212320
/// - parameter options: Options for writing the data. Default value is `[]`.
23222321
/// - throws: An error in the Cocoa domain, if there is an error writing to the `URL`.
23232322
public func write(to url: URL, options: Data.WritingOptions = []) throws {
2323+
#if os(WASI)
2324+
throw NSError(domain: NSPOSIXErrorDomain, code: Int(ENOTSUP), userInfo: nil)
2325+
#else
23242326
// this should not be marked as inline since in objc contexts we correct atomicity via _shouldUseNonAtomicWriteReimplementation
23252327
try _representation.withInteriorPointerReference {
23262328
#if DEPLOYMENT_RUNTIME_SWIFT
@@ -2334,8 +2336,8 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
23342336
}
23352337
#endif
23362338
}
2337-
}
23382339
#endif
2340+
}
23392341

23402342
// MARK: -
23412343

0 commit comments

Comments
 (0)