We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
st_blksize
1 parent 4440638 commit 41cbea8Copy full SHA for 41cbea8
Sources/FoundationEssentials/FileManager/FileOperations.swift
@@ -872,7 +872,16 @@ 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
+ let chunkSize: Int
880
+ if fileInfo.st_blksize > 0 {
881
+ chunkSize = Int(fileInfo.st_blksize)
882
+ } else {
883
+ chunkSize = defaultChunkSize
884
+ }
885
var current: off_t = 0
886
887
#if os(WASI)
0 commit comments