yruslan/reed

Implement File Space abstraction

Opened this issue · 0 comments

Background

'File Space' is what I call an abstraction that creates a view on the top of a list of files that looks like block storage.
This will be used to create recovery info and recover files later.

  • Each block belongs to one of the files in the list.
  • If a file is bigger than the block size, several blocks belong to the file.
  • If size of a file does not evenly divide block size, the last block of the file will be padded with bytes of 0x00
  • The order of files in the list matters
|     file 1   |         file2             |  file3   |
-------------------------------------------------------
|block0|block1|block2|
               |block3|block4|block5|block6|block7|block8|

block2 contains some bytes of file1 padded with zeros
block8 contains some bytes of file3 padded with zeros

Feature

FileSpace (baseDirectory string, files [] string, blockSize int) {
  + getNumberOfBlocks() int64
  + getBlock(block) [] byte // return a slice that has the length of blockSize
}