mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Try lstat
This commit is contained in:
parent
9536cb0da0
commit
03af8a850c
1 changed files with 11 additions and 3 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import Foundation
|
||||
|
||||
public func fileSize(_ path: String, useTotalFileAllocatedSize: Bool = false) -> Int64? {
|
||||
if useTotalFileAllocatedSize {
|
||||
/*if useTotalFileAllocatedSize {
|
||||
let url = URL(fileURLWithPath: path)
|
||||
if let values = (try? url.resourceValues(forKeys: Set([.isRegularFileKey, .fileAllocatedSizeKey]))) {
|
||||
if values.isRegularFile ?? false {
|
||||
|
|
@ -10,10 +10,18 @@ public func fileSize(_ path: String, useTotalFileAllocatedSize: Bool = false) ->
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
var value = stat()
|
||||
if stat(path, &value) == 0 {
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue