Auflistung von Files auf gemounteten Drives

This commit is contained in:
Gerrit Linnemann 2020-08-16 11:30:00 +02:00
parent 6037240052
commit bc3da08d0c
4 changed files with 27 additions and 2 deletions

View File

@ -328,6 +328,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.adawim.macos.YAPS;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
@ -349,6 +350,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.adawim.macos.YAPS;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;

View File

@ -49,7 +49,7 @@ class FinderHelper {
var fileList = [YapsFile]()
do {
let items = try fm.contentsOfDirectory(at: path, includingPropertiesForKeys: nil, options: .skipsHiddenFiles).filter{ $0.pathExtension == "jpg" || $0.pathExtension == "jpeg" }
let items = try fm.contentsOfDirectory(at: path, includingPropertiesForKeys: [.volumeNameKey, .volumeIsRemovableKey, .volumeIsEjectableKey], options: [.skipsHiddenFiles, .skipsPackageDescendants]).filter{ $0.pathExtension.lowercased() == "jpg" || $0.pathExtension.lowercased() == "jpeg" }
var index = 0
for item in items {
@ -149,4 +149,25 @@ class FinderHelper {
return URL(fileURLWithPath: fullPathRAW)
}
func listMounts() -> [URL] {
var mounts: [URL] = [URL]()
let keys: [URLResourceKey] = [.volumeNameKey, .volumeIsRemovableKey, .volumeIsEjectableKey]
let paths = FileManager().mountedVolumeURLs(includingResourceValuesForKeys: keys, options: [])
if let urls = paths {
for url in urls {
let components = url.pathComponents
if components.count > 1
&& components[1] == "Volumes"
&& !(components[2].contains("ime") && components[2].contains("achine")) // skip TimeMachine ^^
{
print(url)
mounts.append(url)
}
}
}
return mounts
}
}

View File

@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>

View File

@ -8,5 +8,7 @@
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.files.bookmarks.app-scope</key>
<true/>
</dict>
</plist>