@@ -50,7 +50,7 @@ module System.Posix.Files.Common (
50
50
getFdStatus ,
51
51
-- ** Querying file status
52
52
deviceID , fileID , fileMode , linkCount , fileOwner , fileGroup ,
53
- specialDeviceID , fileSize , accessTime , modificationTime ,
53
+ specialDeviceID , fileSize , blockSize , blocksCount , accessTime , modificationTime ,
54
54
statusChangeTime ,
55
55
accessTimeHiRes , modificationTimeHiRes , statusChangeTimeHiRes ,
56
56
setFdTimesHiRes , touchFd ,
@@ -234,6 +234,11 @@ setFileCreationMask mask = c_umask mask
234
234
-- -----------------------------------------------------------------------------
235
235
-- stat() support
236
236
237
+ -- TODO: Those values should be defined in package base
238
+ -- and correct type should be used. CSsize works, but without guarantee
239
+ type BlockSize = CSsize
240
+ type BlocksCount = CSsize
241
+
237
242
-- | POSIX defines operations to get information, such as owner, permissions,
238
243
-- size and access times, about a file. This information is represented by the
239
244
-- 'FileStatus' type.
@@ -258,6 +263,10 @@ specialDeviceID :: FileStatus -> DeviceID
258
263
-- | Size of the file in bytes. If this file is a symbolic link the size is
259
264
-- the length of the pathname it contains.
260
265
fileSize :: FileStatus -> FileOffset
266
+ -- | BlockSize for file
267
+ blockSize :: FileStatus -> BlockSize
268
+ -- | Number of blocks
269
+ blocksCount :: FileStatus -> BlocksCount
261
270
-- | Time of last access.
262
271
accessTime :: FileStatus -> EpochTime
263
272
-- | Time of last access in sub-second resolution.
@@ -287,6 +296,10 @@ specialDeviceID (FileStatus stat) =
287
296
unsafePerformIO $ withForeignPtr stat $ (# peek struct stat, st_rdev)
288
297
fileSize (FileStatus stat) =
289
298
unsafePerformIO $ withForeignPtr stat $ (# peek struct stat, st_size)
299
+ blockSize (FileStatus stat) =
300
+ unsafePerformIO $ withForeignPtr stat $ (# peek struct stat, st_blksize)
301
+ blocksCount (FileStatus stat) =
302
+ unsafePerformIO $ withForeignPtr stat $ (# peek struct stat, st_blocks)
290
303
accessTime (FileStatus stat) =
291
304
unsafePerformIO $ withForeignPtr stat $ (# peek struct stat, st_atime)
292
305
modificationTime (FileStatus stat) =
0 commit comments