Skip to content

Add BlockSize and BlocksCount fields for FileStatus #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion System/Posix/Files.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ module System.Posix.Files (
getFileStatus, getFdStatus, getSymbolicLinkStatus,
-- ** Querying file status
deviceID, fileID, fileMode, linkCount, fileOwner, fileGroup,
specialDeviceID, fileSize, accessTime, modificationTime,
specialDeviceID, fileSize, blockSize, blocksCount, accessTime, modificationTime,
statusChangeTime,
accessTimeHiRes, modificationTimeHiRes, statusChangeTimeHiRes,
isBlockDevice, isCharacterDevice, isNamedPipe, isRegularFile,
Expand Down
10 changes: 9 additions & 1 deletion System/Posix/Files/Common.hsc
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module System.Posix.Files.Common (
getFdStatus,
-- ** Querying file status
deviceID, fileID, fileMode, linkCount, fileOwner, fileGroup,
specialDeviceID, fileSize, accessTime, modificationTime,
specialDeviceID, fileSize, blockSize, blocksCount, accessTime, modificationTime,
statusChangeTime,
accessTimeHiRes, modificationTimeHiRes, statusChangeTimeHiRes,
setFdTimesHiRes, touchFd,
Expand Down Expand Up @@ -250,6 +250,10 @@ specialDeviceID :: FileStatus -> DeviceID
-- | Size of the file in bytes. If this file is a symbolic link the size is
-- the length of the pathname it contains.
fileSize :: FileStatus -> FileOffset
-- | BlockSize for file
blockSize :: FileStatus -> CBlkSize
-- | Number of blocks
blocksCount :: FileStatus -> CBlkCnt
-- | Time of last access.
accessTime :: FileStatus -> EpochTime
-- | Time of last access in sub-second resolution.
Expand Down Expand Up @@ -279,6 +283,10 @@ specialDeviceID (FileStatus stat) =
unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_rdev)
fileSize (FileStatus stat) =
unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_size)
blockSize (FileStatus stat) =
unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_blksize)
blocksCount (FileStatus stat) =
unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_blocks)
accessTime (FileStatus stat) =
unsafePerformIO $ withForeignPtr stat $ (#peek struct stat, st_atime)
modificationTime (FileStatus stat) =
Expand Down