Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions SharedLibrary/Extension/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,7 @@ public extension String {
}

var splittedByWhitespace: [String] {
guard let trimWhiteSpaceRegEx = try? NSRegularExpression(pattern: "/ +/g") else {
return []
}
let trimmed = trimWhiteSpaceRegEx.stringByReplacingMatches(
in: self,
options: [],
range: NSRange(location: 0, length: count),
withTemplate: " "
)
return trimmed.split(separator: " ").map { String($0) }
split(separator: " ").filter { !$0.isEmpty }.map { String($0) }
}

var numericOnly: String {
Expand Down
21 changes: 19 additions & 2 deletions eul/Store/DiskStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,29 @@ class DiskStore: ObservableObject, Refreshable {
return list?.disks.filter { $0.name == config.diskSelection }.first
}

private var rootAttributes: (size: UInt64, free: UInt64)? {
guard
let attrs = try? FileManager.default.attributesOfFileSystem(forPath: "/"),
let size = attrs[.systemSize] as? UInt64,
let free = attrs[.systemFreeSize] as? UInt64
else {
return nil
}
return (size, free)
}

var ceilingBytes: UInt64? {
selectedDisk?.size ?? list?.disks.reduce(0) { $0 + $1.size }
if let selected = selectedDisk {
return selected.size
}
return rootAttributes?.size
}

var freeBytes: UInt64? {
selectedDisk?.freeSize ?? list?.disks.reduce(0) { $0 + $1.freeSize }
if let selected = selectedDisk {
return selected.freeSize
}
return rootAttributes?.free
}

var usageString: String {
Expand Down
Loading