Need to know how to … get the root folder
For a file system URL, you can get the root of the volume using the
.volumeURLKey
. For example:
let u = URL(fileURLWithPath: "/Volumes/SDKCentral/MacOSX10.14.sdk/", isDirectory: true)
let info = try u.resourceValues(forKeys: [.volumeURLKey])
print(info.volume!) // prints: file:///Volumes/SDKCentral/
check if files or directories are on same volume
The canonically correct way to do this is with
.volumeIdentifierKey
.
copy
There’s nothing special here;
FileManager
will just as easily copy between volumes as it does within a volume.
move from one to another etc?
FileManager
will also move between volumes. Be aware that this is not supported directly by the underlying file system. To accomplish this,
FileManager
does a copy then delete.
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"