|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Object FileTester
Basic driver program to be used as a shell for the MiniKernel for project 5. It can be run in two modes:
The testfile consists of commands to the driver program (one per line) as well as comments. Comments beginning with /* will be ignored completely by the driver. Comments beginning with // will be echoed to the output.
See the test files test*.data for examples.
Field Summary | |
private static String[] |
helpInfo
Synopsis of commands. |
Constructor Summary | |
FileTester()
|
Method Summary | |
private static void |
help()
Prints a list of available commands. |
private static void |
help(String cmd)
Prints help for command "cmd". |
static void |
main(String[] args)
Main program. |
private static void |
pl(Object o)
Prints a line to System.out followed by a newline. |
private static void |
pr(char c)
Prints a character to System.out. |
private static void |
pr(Object o)
Prints a line to System.out. |
private static int |
readTest(String fname,
int offset,
int size)
Reads data from a (simulated) file using Library.read and displays the results. |
private static void |
showChar(int b)
Display a readable representation of a byte. |
private static int |
writeTest(String fname,
int offset,
BufferedReader in)
Write data to a (simulated) file using Library.write. |
private static int |
writeTest(String fname,
int offset,
int size,
String data)
Writes data to a (simulated) file using Library.write. |
Methods inherited from class Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static String[] helpInfo
Constructor Detail |
public FileTester()
Method Detail |
public static void main(String[] args)
args
- command-line arguments (there should be at most one:
the name of a test file from which to read commands).private static void help()
private static void help(String cmd)
cmd
- the name of the command.private static int readTest(String fname, int offset, int size)
fname
- the name of the file.offset
- the starting position in the file.size
- the number of bytes to read.
private static int writeTest(String fname, int offset, int size, String data)
fname
- the name of the file.offset
- the starting location in the file.size
- the number of bytes to write.data
- a source of data.
private static int writeTest(String fname, int offset, BufferedReader in)
fname
- the name of the file.offset
- the starting offset in the file.in
- the source of data.
private static void showChar(int b)
b
- the byte to display as a number in the range 0..255.private static void pl(Object o)
o
- the message to print.private static void pr(Object o)
o
- the message to print.private static void pr(char c)
c
- the character to print.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |