mirror of
https://github.com/GLEGram/GLEGram-iOS.git
synced 2026-04-25 12:26:55 +02:00
4647310322
Based on Swiftgram 12.5 (Telegram iOS 12.5). All GLEGram features ported and organized in GLEGram/ folder. Features: Ghost Mode, Saved Deleted Messages, Content Protection Bypass, Font Replacement, Fake Profile, Chat Export, Plugin System, and more. See CHANGELOG_12.5.md for full details.
34 lines
1009 B
Swift
34 lines
1009 B
Swift
import Foundation
|
|
|
|
// Incuding at least one Objective-C class in a swift file ensures that it doesn't get stripped by the linker
|
|
private final class LinkHelperClass: NSObject {
|
|
}
|
|
|
|
public func fileSize(_ path: String, useTotalFileAllocatedSize: Bool = false) -> Int64? {
|
|
/*if useTotalFileAllocatedSize {
|
|
let url = URL(fileURLWithPath: path)
|
|
if let values = (try? url.resourceValues(forKeys: Set([.isRegularFileKey, .fileAllocatedSizeKey]))) {
|
|
if values.isRegularFile ?? false {
|
|
if let fileSize = values.fileAllocatedSize {
|
|
return Int64(fileSize)
|
|
}
|
|
}
|
|
}
|
|
}*/
|
|
|
|
var value = stat()
|
|
if lstat(path, &value) == 0 {
|
|
if (value.st_mode & S_IFMT) == S_IFLNK {
|
|
return 0
|
|
}
|
|
|
|
if useTotalFileAllocatedSize {
|
|
return Int64(value.st_blocks) * Int64(value.st_blksize)
|
|
}
|
|
|
|
return value.st_size
|
|
} else {
|
|
return nil
|
|
}
|
|
}
|