Avatar
Avatar
omochimetaru
@swift-5.10.1 @swift-6.0.3 import Foundation let swiftDir = URL(fileURLWithPath: "src/swift", isDirectory: true) let javaDir = URL(fileURLWithPath: "src/java", isDirectory: false) print("exists dir") print(swiftDir.path) print(swiftDir.absoluteURL) print(swiftDir.absoluteURL.path) print(swiftDir.absoluteURL.appendingPathComponent("/")) let doubleSlashDir = URL(fileURLWithPath: "src/swift").absoluteURL.appendingPathComponent("/") print("non exists dir") print(javaDir.path) print(javaDir.absoluteURL) print(javaDir.absoluteURL.path) print(javaDir.absoluteURL.appendingPathComponent("/")) let singleSlashDir = URL(fileURLWithPath: "src/java").absoluteURL.appendingPathComponent("/") let filePath1 = URL(fileURLWithPath: "common.js", relativeTo: doubleSlashDir) let filePath2 = URL(fileURLWithPath: "common.js", relativeTo: singleSlashDir) print("===") print(filePath1) print(filePath1.standardized) print(filePath1.standardized.pathComponents) print("===") print(filePath2) print(filePath2.standardized) print(filePath2.standardized.pathComponents)
swift510 BOT 9/18/2024 2:17 AM
exists dir /tmp/747e629e42d4f14f/src/swift file:///tmp/747e629e42d4f14f/src/swift/ /tmp/747e629e42d4f14f/src/swift file:///tmp/747e629e42d4f14f/src/swift// non exists dir /tmp/747e629e42d4f14f/src/java file:///tmp/747e629e42d4f14f/src/java /tmp/747e629e42d4f14f/src/java file:///tmp/747e629e42d4f14f/src/java/ === common.js -- file:///tmp/747e629e42d4f14f/src/swift/ file:///tmp/747e629e42d4f14f/src/swift/common.js ["/", "tmp", "747e629e42d4f14f", "src", "swift", "common.js"] === common.js -- file:///tmp/747e629e42d4f14f/src/java/ file:///tmp/747e629e42d4f14f/src/java/common.js ["/", "tmp", "747e629e42d4f14f", "src", "java", "common.js"]