Are they different or simple aliases?
I obtain the /private/var by running:
FileManager.default.contentsOfDirectory(at: folder, includingPropertiesForKeys: [], options: [])
And the second is created with a simple:
data.write(to: f, options: [.atomic])
where f is in the same directory as "folder"
From The iPhone Wiki. /private/var/mobile is a folder in the iOS filesystem. Inside it, the (root)/private/var/containers/Bundle/Application folder contains some app store apps, though others may be located in .
The Veteran Appointment Request (VAR) mobile application (app) allows Veterans who are in the Department of Veterans Affairs (VA) health care system to self-schedule and request primary care appointments.
That are the same directories, as one can verify by retrieving the “canonical path” for both:
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"
}
In fact, /var
is a symbolic link to /private/var
:
var buffer = Array<Int8>(repeating: 0, count: 1024)
if readlink("/var", &buffer, buffer.count) > 0 {
print(String(cString: &buffer))
// "private/var"
}
For Swift users, using URL.standardizedFileURL
eliminates the ambiguity/confusion caused by paths which contain soft links or other different elements that ultimately resolve to the same file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With