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 4440638 commit bb01d84Copy full SHA for bb01d84
Sources/FoundationEssentials/FileManager/FileOperations.swift
@@ -872,7 +872,14 @@ enum _FileOperations {
872
}
873
874
let total: Int = Int(fileInfo.st_size)
875
- let chunkSize: Int = Int(fileInfo.st_blksize)
+ // Respect the optimal block size for the file system if available
876
+ // Some platforms including WASI don't provide this information, so we
877
+ // fall back to the default chunk size 4KB, which is a common page size.
878
+ let defaultChunkSize = 1024 * 4 // 4KB
879
+ var chunkSize: Int = defaultChunkSize
880
+ if fileInfo.st_blksize > 0 {
881
+ chunkSize = Int(fileInfo.st_blksize)
882
+ }
883
var current: off_t = 0
884
885
#if os(WASI)
0 commit comments