mirror of
https://github.com/apple/swift-foundation.git
synced 2025-05-22 13:39:25 +08:00
* (120741818) Port FileManager to swift-foundation * (120741818) Fix linux test failures * (120741818) Fix build failures
42 lines
1.4 KiB
Swift
42 lines
1.4 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
|
|
}
|
|
|
|
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
|