Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The squareroot directory squareroot and file allocation table FAT will be needed for problens 1, 2 and 3. squareroot and FAT are tables defined as
The squareroot directory squareroot and file allocation table FAT will be needed for problens 1, 2 and 3. squareroot and FAT are tables defined as follows. The squareroot table has 6 entries and the FAT has 16 entries. The first colunn of the squareroot is the file nane and the second column indicates the first block of the file. The only colunn of the FAT is the link field which indicates the next block in the file. In the FAT, a 0 indicates the entry is the last block in the file. The first free Block in the free list is given in FAT(theta). The functions Firstblock(F) and Nextblock(F, I) are also members of the FileSys class. Firstblock(F) returns the number of the first block in the file F (returns -1 if the file does not exist and returns 0 if the file has no blocks). Nextblock accepts a file name F and a block number I and returns the block number of the block that follows I in the file F. It returns 0 if I is the last block in the -1 if I does not belong to the file. Use Firstblock, Nextblock, and Delblock to write a function: int clobber(FileSys& filesystem, string file) which accepts a file name "file" and clobbers the file. That is, the function deletes every block in the file leaving the file empty. Note the file remains in the squareroot list, but it has a first block equal to 0. Note that your function may not directly access or modify the FAT or squareroot. It must use Firstblock, Nextblock, and Delblock
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started