NSWorkspace
) Es bekommen.FileManager
unter mountVolumeURLs \ (einschließlich ResourceValuesForKeys: options: ). ..――Ich möchte verschiedene Dinge sehen, daher führe ich es mit einigen Geräten aus, die mit dem Server verbunden oder verbunden sind.
/
aus folgenden Gründen nicht aus macOS 11.0 geschrieben werden kann.Dieser Band ist schreibgeschützt, "Macintosh HD"
:/
--Dateien und Daten sind "Macintosh HD --Data"
:/ System / Volumes / Data /
macOS 11.0
*********
/ /*Root-Verzeichnis*/
is not removal media
is not writable
is not unmountable
apfs apfs
*********
/Volumes/BOOTCAMP
is not removal media
is writable
is not unmountable
ntfs ntfs
*********
/Volumes/Untitled 1 /*USB-Speicher*/
is removal media
is writable
is unmountable
msdos msdos
*********
/Volumes/<Servername> /*Server mit jdb verbunden*/
is not removal media
is writable
is unmountable
smbfs smbfs
*********
/Volumes/<DVD-Name> /* DVD */
is removal media
is not writable
is unmountable
hfs hfs
macOS 10.15
*********
/ /*Root-Verzeichnis*/
is not removal media
is writable
is not unmountable
apfs apfs
*********
/Volumes/<Servername> /*Server mit jdb verbunden*/
is not removal media
is writable
is unmountable
smbfs smbfs
*********
/Volumes/Untitled /*USB-Speicher*/
is removal media
is writable
is unmountable
msdos msdos
printVolumesInfo()
private func printVolumesInfo() {
guard let volumeUrls = FileManager.default.mountedVolumeURLs(
includingResourceValuesForKeys: nil,
options: FileManager.VolumeEnumerationOptions.skipHiddenVolumes) else {
return
}
for volumeUrl in volumeUrls {
//Zeigerreferenz in Swift
// [Umgang mit C-Zeigern für Kakao Teil 3\[Swift\] \-Erklärung zur Kakao-API\(macOS/iOS\)](https://cocoaapi.hatenablog.com/entry/2015/04/16/Cocoa%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AEC%E3%83%9D%E3%82%A4%E3%83%B3%E3%82%BF%E3%81%AE%E5%8F%96%E3%82%8A%E6%89%B1%E3%81%84%E3%81%9D%E3%81%AE3)
var isRemoval = ObjCBool(false)
var isWritable = ObjCBool(false)
var isUnmountable = ObjCBool(false)
// AutoreleasingUnsafePointer<NSString?>Erhalten
// [Swift: How to get the value from a AutoreleasingUnsafePointer<NSString?> from a NSScanner?](https://stackoverflow.com/questions/24205768/swift-how-to-get-the-value-from-a-autoreleasingunsafepointernsstring-from-a/24206064#24206064)
var description: NSString? = nil
var type: NSString? = nil
NSWorkspace.shared.getFileSystemInfo(forPath: volumeUrl.path,
isRemovable: &isRemoval,
isWritable: &isWritable,
isUnmountable: &isUnmountable,
description: &description,
type: &type)
let descriptionForPrint = description as String?
let typeForPrint = type as String?
var diskInfo = ""
if let descriptionForPrint = descriptionForPrint {
diskInfo = diskInfo.appending(descriptionForPrint)
}
if let typeForPrint = typeForPrint {
diskInfo = diskInfo.appendingFormat("%@%@", diskInfo.isEmpty ? "" : ", " , typeForPrint)
}
print(
"""
*******
\(volumeUrl.path)
\(FileManager.default.displayName(atPath: volumeUrl.path))
\(isRemoval.boolValue ? "is removal media" : "is not removal media")
\(isWritable.boolValue ? "is writable" : "is not writable")
\(isUnmountable.boolValue ? "is unmountable" : "is not unmountable")
\(diskInfo)
""")
}
}
Recommended Posts