-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
20 changed files
with
464 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// | ||
// FileManager+SizeOfFile.swift | ||
// RxNetworkKit | ||
// | ||
// Created by Loay Ashraf on 25/05/2024. | ||
// | ||
|
||
import Foundation | ||
|
||
extension FileManager { | ||
func sizeOfFile(atPath path: String) -> Int64? { | ||
guard let attrs = try? attributesOfItem(atPath: path) else { | ||
return nil | ||
} | ||
return attrs[.size] as? Int64 | ||
} | ||
|
||
func sizeOfFile(atURL url: URL) -> Int64? { | ||
guard let attributes = try? attributesOfItem(atPath: url.path) else { | ||
return nil | ||
} | ||
return attributes[.size] as? Int64 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Int64+FormattedSize.swift | ||
// RxNetworkKit | ||
// | ||
// Created by Loay Ashraf on 25/05/2024. | ||
// | ||
|
||
import Foundation | ||
|
||
extension Int64 { | ||
var formattedSize: String { | ||
let bcf = ByteCountFormatter() | ||
bcf.allowedUnits = [.useKB, .useMB, .useGB] | ||
bcf.countStyle = .file | ||
let size = bcf.string(fromByteCount: self) | ||
return size | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.