Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Sources/SkipFoundation/Data.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public struct Data : DataProtocol, Hashable, CustomStringConvertible, Codable, K

public init(contentsOf url: URL, options: Data.ReadingOptions = []) throws {
if url.scheme == "content" {
let uri = android.net.Uri.parse(url.absoluteString)
let uri = url.toAndroidUri()
if let inputStream = ProcessInfo.processInfo.androidContext.getContentResolver().openInputStream(uri) {
self.platformValue = inputStream.readAllBytes()
do { inputStream.close() } catch {}
Expand Down Expand Up @@ -320,7 +320,7 @@ public struct Data : DataProtocol, Hashable, CustomStringConvertible, Codable, K

@available(*, unavailable)
public static let uncached = ReadingOptions(rawValue: 2)

@available(*, unavailable)
public static let alwaysMapped = ReadingOptions(rawValue: 4)
}
Expand Down
5 changes: 5 additions & 0 deletions Sources/SkipFoundation/URL.swift
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ public struct URL : Hashable, CustomStringConvertible, Codable, KotlinConverting
return java.nio.file.Paths.get(absoluteURL.platformValue)
}

/// Converts this URL to a `android.net.Uri`.
public func toAndroidUri() -> android.net.Uri {
return android.net.Uri.parse(absoluteString)
}

public var host: String? {
return absoluteURL.platformValue.host
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/SkipFoundation/URLSessionTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class URLSessionTask {

public var countOfBytesClientExpectsToReceive = Int64(-1)
public var countOfBytesClientExpectsToSend = Int64(-1)

@available(*, unavailable)
public let progress: Any? = nil /* Progress(totalUnitCount: -1) */

Expand Down Expand Up @@ -396,7 +396,7 @@ public class URLSessionWebSocketTask : URLSessionTask {
}

public var maximumMessageSize: Int = 1 * 1024 * 1024

public var closeCode: CloseCode {
return lock.withLock { _closeCode } ?? .invalid
}
Expand Down Expand Up @@ -775,7 +775,7 @@ private func contentResponse(for request: URLRequest, with url: URL, isForRespon
}
var inputStream: java.io.InputStream? = nil
return withTaskCancellationHandler {
let uri = android.net.Uri.parse(url.absoluteString)
let uri = url.toAndroidUri()
let outputStream = java.io.ByteArrayOutputStream()
inputStream = ProcessInfo.processInfo.androidContext.getContentResolver().openInputStream(uri)
if let inputStream {
Expand Down