mirror of
https://github.com/apple/swift-foundation.git
synced 2025-05-24 23:06:21 +08:00
* Provide public access for some internal functions, to enable swift-corelibs-foundation * Add access to TimeZone internals for swift-corelibs-foundation * Fix default TimeZone for Linux * Remove unneeded private entry point * Do not use a recursive definition of description for String.Encoding * Merge in some WASI changes and other Data fixes * Add temporary initializer to the stub URL * Remove Hashable conformance for CocoaError. This allows userInfo to be Any instead of AnyHashable * Remove some protocols which depend on NSError from swift-foundation -- they will live in swift-corelibs-foundation * Adjust the debug description of the GMT ICU calendar to be a little less implementation-specific * Use an English-only description for string encodings, for compatibility with existing SCL-F clients * Use a more compatible definition of a backstop value for Bundle
48 lines
1.6 KiB
Swift
48 lines
1.6 KiB
Swift
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See https://swift.org/LICENSE.txt for license information
|
|
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#if !FOUNDATION_FRAMEWORK
|
|
|
|
public struct URL : Hashable, Sendable, Codable {
|
|
public let path: String
|
|
|
|
enum DirectoryHint {
|
|
case isDirectory
|
|
}
|
|
internal init(filePath: String, directoryHint: DirectoryHint = .isDirectory) {
|
|
self.path = filePath
|
|
}
|
|
internal init(fileURLWithPath: String, isDirectory: Bool? = nil) {
|
|
self.path = fileURLWithPath
|
|
}
|
|
|
|
// Temporary initializer, just to be able to stash URLs in things without any functionality.
|
|
@_spi(SwiftCorelibsFoundation)
|
|
public init(path: String) {
|
|
self.path = path
|
|
}
|
|
|
|
public var isFileURL: Bool { true }
|
|
public var lastPathComponent: String { path.lastPathComponent }
|
|
public var scheme: String? { "file" }
|
|
|
|
internal func path(percentEncoded: Bool = true) -> String { self.path }
|
|
|
|
internal func withUnsafeFileSystemRepresentation<ResultType>(_ block: (UnsafePointer<Int8>?) throws -> ResultType) rethrows -> ResultType {
|
|
try path.withFileSystemRepresentation(block)
|
|
}
|
|
}
|
|
|
|
public struct URLResourceKey {}
|
|
|
|
#endif // !FOUNDATION_FRAMEWORK
|