Class FileTester

Object
  extended byFileTester

public class FileTester
extends Object

Basic driver program to be used as a shell for the MiniKernel for project 5. It can be run in two modes:

Interactive:
java Boot ... FileTester
With a test script file:
java Boot ... FileTester script
To get a list of supported commands, type 'help' at the command prompt.

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

helpInfo

private static String[] helpInfo
Synopsis of commands.

Constructor Detail

FileTester

public FileTester()
Method Detail

main

public static void main(String[] args)
Main program.

Parameters:
args - command-line arguments (there should be at most one: the name of a test file from which to read commands).

help

private static void help()
Prints a list of available commands.


help

private static void help(String cmd)
Prints help for command "cmd".

Parameters:
cmd - the name of the command.

readTest

private static int readTest(String fname,
                            int offset,
                            int size)
Reads data from a (simulated) file using Library.read and displays the results.

Parameters:
fname - the name of the file.
offset - the starting position in the file.
size - the number of bytes to read.
Returns:
the result of the Library.read call.

writeTest

private static int writeTest(String fname,
                             int offset,
                             int size,
                             String data)
Writes data to a (simulated) file using Library.write.

Parameters:
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.
Returns:
the result of the Library.write call.

writeTest

private static int writeTest(String fname,
                             int offset,
                             BufferedReader in)
Write data to a (simulated) file using Library.write. Data comes from the following lines in the input stream.

Parameters:
fname - the name of the file.
offset - the starting offset in the file.
in - the source of data.
Returns:
the result of the Library.write call.

showChar

private static void showChar(int b)
Display a readable representation of a byte.

Parameters:
b - the byte to display as a number in the range 0..255.

pl

private static void pl(Object o)
Prints a line to System.out followed by a newline.

Parameters:
o - the message to print.

pr

private static void pr(Object o)
Prints a line to System.out.

Parameters:
o - the message to print.

pr

private static void pr(char c)
Prints a character to System.out.

Parameters:
c - the character to print.