public class TestFileSystem
{
  public static void main(String[] args)
  {
    FileSystem fs = new FileSystem();
    fs.formatDisk(20, 10);
    System.out.println(fs.sb);

    int fd = fs.create(5);                  // create file with filename 5
    System.out.println("Creating file:");
    System.out.println(fs.ft);

    byte[] buffer = new byte[5];            // test buffer for writing
    buffer[0] = 'a';
    buffer[1] = 'b';
    buffer[2] = 'c';
    buffer[3] = 'd';
    buffer[4] = 'e'; 
    fs.write(fd, buffer);                   // write to file
    System.out.println("Writing to file:");
    System.out.println(fs.ft);

    fs.close(fd);                           // close file

    fd = fs.open(5);                        // open file
    System.out.println("\nOpening file:");
    System.out.println(fs.ft);

    byte[] buffer2 = new byte[5];           // test buffer for reading
    fs.read(fd, buffer2);                   // read file
    System.out.println("Dumping the file content:");
    for (int i=0; i<buffer2.length; i++)    // dump the read buffer
      System.out.print((char)buffer2[i]);
    System.out.println(); 

    System.out.println(fs.ft);
    fs.close(fd);                           // close file
  }
}
