We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
st_blksize
1 parent 835e7a8 commit 968a3fbCopy full SHA for 968a3fb
Sources/FoundationEssentials/FileManager/FileOperations.swift
@@ -881,7 +881,16 @@ enum _FileOperations {
881
}
882
883
let total: Int = Int(fileInfo.st_size)
884
- let chunkSize: Int = Int(fileInfo.st_blksize)
+ // Respect the optimal block size for the file system if available
885
+ // Some platforms including WASI don't provide this information, so we
886
+ // fall back to the default chunk size 4KB, which is a common page size.
887
+ let defaultChunkSize = 1024 * 4 // 4KB
888
+ let chunkSize: Int
889
+ if fileInfo.st_blksize > 0 {
890
+ chunkSize = Int(fileInfo.st_blksize)
891
+ } else {
892
+ chunkSize = defaultChunkSize
893
+ }
894
var current: off_t = 0
895
896
#if os(WASI)
0 commit comments