gpt4 book ai didi

ios - ios文件:///var/mobile/Containers and file:///private/var/mobile/Containers?之间有什么区别

转载 作者:搜寻专家 更新时间:2023-10-31 22:18:12 31 4
gpt4 key购买 nike

它们是不同的还是简单的别名?

我通过运行获取/private/var:

FileManager.default.contentsOfDirectory(at: folder, includingPropertiesForKeys: [], options: [])

第二个是用简单的方式创建的:

data.write(to: f, options: [.atomic]) 

其中 f 与“文件夹”在同一目录中

最佳答案

这是相同的目录,可以通过检索两者的“规范路径”:

let url1 = URL(fileURLWithPath: "/var/mobile/Containers/")
if let cp = (try? url1.resourceValues(forKeys: [.canonicalPathKey]))?.canonicalPath {
print(cp)
// "/private/var/mobile/Containers"

}
let url2 = URL(fileURLWithPath: "/private/var/mobile/Containers/")
if let cp = (try? url2.resourceValues(forKeys: [.canonicalPathKey]))?.canonicalPath {
print(cp)
// "/private/var/mobile/Containers"
}

事实上,/var是一个指向/private/var的符号链接(symbolic link):

var buffer = Array<Int8>(repeating: 0, count: 1024)
if readlink("/var", &buffer, buffer.count) > 0 {
print(String(cString: &buffer))
// "private/var"
}

关于ios - ios文件:///var/mobile/Containers and file:///private/var/mobile/Containers?之间有什么区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49391830/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com