Back to problems

Compute File Size on Disk

Algorithm · Upstart · Easy

Write a function computeSizeOnDisk(clusterSize, fileSize) that returns the total bytes physically occupied by a file on disk. The file system allocates space in clusters of a fixed size. Even if the last cluster is only partially filled, it still counts as a whole cluster. clusterSize: positive integer, the size of one cluster in bytes. fileSize: non-negative integer, the logical size of the file in bytes. The function should return the total allocated bytes on disk. If…

Checking your access…