Ticket #7345: fileBlocks.patch

File fileBlocks.patch, 1.9 KB (added by JohnWiegley, 2 years ago)
  • System/Posix/Files/Common.hsc

    diff --git a/System/Posix/Files/Common.hsc b/System/Posix/Files/Common.hsc
    index cdbd07f..b74b7ff 100644
    a b module System.Posix.Files.Common ( 
    5252    getFdStatus, 
    5353    -- ** Querying file status 
    5454    deviceID, fileID, fileMode, linkCount, fileOwner, fileGroup, 
    55     specialDeviceID, fileSize, accessTime, modificationTime, 
    56     statusChangeTime, 
     55    specialDeviceID, fileSize, fileBlockSize, optimalBlockSize, 
     56    accessTime, modificationTime, statusChangeTime, 
    5757    accessTimeHiRes, modificationTimeHiRes, statusChangeTimeHiRes, 
    5858    isBlockDevice, isCharacterDevice, isNamedPipe, isRegularFile, 
    5959    isDirectory, isSymbolicLink, isSocket, 
    specialDeviceID :: FileStatus -> DeviceID 
    234234-- | Size of the file in bytes. If this file is a symbolic link the size is 
    235235-- the length of the pathname it contains. 
    236236fileSize         :: FileStatus -> FileOffset 
     237-- | Size of the file in filesystem blocks. If this file is a symbolic link 
     238-- the size is the length of the pathname it contains. 
     239fileBlockSize    :: FileStatus -> FileOffset 
     240-- | Optimal blocksize for I/O. 
     241optimalBlockSize :: FileStatus -> FileOffset 
    237242-- | Time of last access. 
    238243accessTime       :: FileStatus -> EpochTime 
    239244-- | Time of last access in sub-second resolution. 
    specialDeviceID (FileStatus stat) = 
    263268  unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_rdev) 
    264269fileSize (FileStatus stat) = 
    265270  unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_size) 
     271fileBlockSize (FileStatus stat) = 
     272  unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_blocks) 
     273optimalBlockSize (FileStatus stat) = 
     274  unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_blksize) 
    266275accessTime (FileStatus stat) = 
    267276  unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_atime) 
    268277modificationTime (FileStatus stat) =