func spt_forceLinkItem()

in Sources/XCRemoteCache/FileAccess/FileManager.swift [48:63]


    func spt_forceLinkItem(at srcURL: URL, to dstURL: URL) throws {
        let destLink = try? destinationOfSymbolicLink(atPath: dstURL.path)
        if destLink == srcURL.path {
            // Already linked to the right destination
            return
        }
        if fileExists(atPath: dstURL.path) {
            try removeItem(at: dstURL)
        } else {
            let parentDir = dstURL.deletingLastPathComponent()
            if !fileExists(atPath: parentDir.path) {
                try createDirectory(at: parentDir, withIntermediateDirectories: true, attributes: nil)
            }
        }
        try linkItem(at: srcURL, to: dstURL)
    }