Skip to content

Commit

Permalink
[wasm] Make Data.write(to:options:) API surface available on WASI
Browse files Browse the repository at this point in the history
But its implementation will throw an error if called.
  • Loading branch information
kateinoigakukun committed May 29, 2024
1 parent ba532b0 commit 1972782
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Sources/Foundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2314,13 +2314,15 @@ public struct Data : ReferenceConvertible, Equatable, Hashable, RandomAccessColl
}
#endif

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

// MARK: -

Expand Down

0 comments on commit 1972782

Please sign in to comment.