Answered step by step
Verified Expert Solution
Question
1 Approved Answer
2 . 3 . Read and Write Methods. There are two types of read and write methods that have to be implemented: Methods with absolute
Read and Write Methods. There are two types of read and write methods that have to be implemented:
Methods with absolute addressing eg readBlock and methods that address relative to the current page of a file
eg readNextBlock
readBlock
The method reads the block at position pageNum from a file and stores its content in the memory pointed
to by the memPage page handle.
If the file has less than pageNum pages, the method should return RCREADNONEXISTINGPAGE.
getBlockPos
Return the current page position in a file
readFirstBlock, readLastBlock
Read the first respective last page in a file
readPreviousBlock, readCurrentBlock, readNextBlock
Read the current, previous, or next page relative to the curPagePos of the file.
The curPagePos should be moved to the page that was read.
If the user tries to read a block before the first page or after the last page of the file, the method should
return RCREADNONEXISTINGPAGE.
writeBlock, writeCurrentBlock
Write a page to disk using either the current position or an absolute position.
appendEmptyBlock
Increase the number of pages in the file by one. The new last page should be filled with zero bytes.
ensureCapacity
If the file has less than numberfPages pages then increase the size to numberfPages.
Return codes. The header file dberror.h defines several error codes as macros. As you may have noticed,
the storage manager functions all return an RC value. This value should indicate whether an operation was successful
and if not what type of error occurred. If a method call is successful, the function should return RCOK The
printError function can be used to output an error message based on a return code and the message stored in
global variable RCmessage implemented in dberror.c
Source Cone Structure
You source code directories should be structured as follows:
Put all source files in a folder assign in your git repository
This folder should contain at least
the provided header and files
a make file for building your code Makefile. This makefile should create a binary from testassign
from testassignc which requires dberror.c and all your C files implementing the storagemgrh
interface
a bunch of c and h files implementing the storage manager
README.txt : A text file that shortly describes your solution
Example, the structure may look like that:
git
assign
README. txt
dberror.c
dberror. h
storagemgr a c
storagemgr h
testassignc
testhelper.h
Makefile
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