mirror of
https://github.com/morgan9e/macos-stats
synced 2026-04-15 00:34:08 +09:00
fix disk module (read freeSize of disk)
This commit is contained in:
4
Makefile
4
Makefile
@@ -16,7 +16,7 @@ DMG_PATH = $(PWD)/$(APP).dmg
|
||||
all: clean archive notarize sign build
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_PATH)
|
||||
# rm -rf $(BUILD_PATH)
|
||||
|
||||
.PHONY: archive
|
||||
archive: clean
|
||||
@@ -70,7 +70,7 @@ build: sign
|
||||
$(APP_PATH)
|
||||
|
||||
rm -rf ./create-dmg
|
||||
rm -rf $(BUILD_PATH)
|
||||
# rm -rf $(BUILD_PATH)
|
||||
open $(PWD)
|
||||
|
||||
check:
|
||||
|
||||
@@ -758,7 +758,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MARKETING_VERSION = 1.6.3;
|
||||
MARKETING_VERSION = 1.6.4;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@@ -789,7 +789,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.13;
|
||||
MARKETING_VERSION = 1.6.3;
|
||||
MARKETING_VERSION = 1.6.4;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = eu.exelban.Stats;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
||||
@@ -28,33 +28,27 @@ struct disksList {
|
||||
var list: [diskInfo] = []
|
||||
|
||||
func getDiskByBSDName(_ name: String) -> diskInfo? {
|
||||
let idx = self.list.firstIndex { $0.mediaBSDName == name }
|
||||
|
||||
if idx == nil {
|
||||
return nil
|
||||
if let idx = self.list.firstIndex(where: { $0.mediaBSDName == name }) {
|
||||
return self.list[idx]
|
||||
}
|
||||
|
||||
return self.list[idx!]
|
||||
return nil
|
||||
}
|
||||
|
||||
func getDiskByName(_ name: String) -> diskInfo? {
|
||||
let idx = self.list.firstIndex { $0.name == name }
|
||||
|
||||
if idx == nil {
|
||||
return nil
|
||||
if let idx = self.list.firstIndex(where: { $0.name == name }) {
|
||||
return self.list[idx]
|
||||
}
|
||||
|
||||
return self.list[idx!]
|
||||
return nil
|
||||
}
|
||||
|
||||
func getRootDisk() -> diskInfo? {
|
||||
let idx = self.list.firstIndex { $0.root }
|
||||
|
||||
if idx == nil {
|
||||
return nil
|
||||
if let idx = self.list.firstIndex(where: { $0.root }) {
|
||||
return self.list[idx]
|
||||
}
|
||||
|
||||
return self.list[idx!]
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,8 +85,11 @@ class DiskCapacityReader: Reader {
|
||||
let BSDName: String = String(cString: DADiskGetBSDName(disk)!)
|
||||
|
||||
if let _: diskInfo = self.disks.getDiskByBSDName(BSDName) {
|
||||
let idx = self.disks.list.firstIndex { $0.mediaBSDName == BSDName }
|
||||
self.disks.list[idx!].freeSize = freeDiskSpaceInBytes(self.disks.list[idx!].path!.absoluteString)
|
||||
if let idx = self.disks.list.firstIndex(where: { $0.mediaBSDName == BSDName }) {
|
||||
if let path = self.disks.list[idx].path {
|
||||
self.disks.list[idx].freeSize = freeDiskSpaceInBytes(path.absoluteString)
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user