You're working on a file system implementation and need to calculate how much disk space a file actually occupies when stored on disk.
📀 Understanding File Storage:
- Files have two different sizes to consider:
- The actual file size in octets/bytes
- The disk space used, which is always greater than or equal to the file size
- Storage organization:
- Storage is divided into fixed-size "clusters"
- A file can use multiple clusters if needed
- Each cluster can only be used by one file
- The total disk space used is the sum of all clusters allocated to the file
- Important rules:
- You must allocate whole clusters (no partial clusters allowed)
- If a file needs even slightly more than N clusters, you must allocate N+1 clusters
- Empty space in the last cluster is wasted
💡 Quick Example:
For a file of 1500 bytes on a disk with 512-byte clusters:
- 1500 ÷ 512 = 2.93 clusters needed
- We must round up to 3 complete clusters
- Total space used = 3 × 512 = 1536 bytes
🎯 Your Task:
Complete the computeSizeOnDisk method that calculates the actual disk space used by a file, given:
- The size of each cluster (in octets/bytes)
- The size of the file (in octets/bytes)