nachos.machine
Class StubFileSystem

java.lang.Object
  extended by nachos.machine.StubFileSystem
All Implemented Interfaces:
FileSystem

public class StubFileSystem
extends Object
implements FileSystem

This class implements a file system that redirects all requests to the host operating system's file system.


Constructor Summary
StubFileSystem(Privilege privilege, File directory)
          Allocate a new stub file system.
 
Method Summary
 OpenFile open(String name, boolean truncate)
          Atomically open a file, optionally creating it if it does not already exist.
 boolean remove(String name)
          Atomically remove an existing file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StubFileSystem

public StubFileSystem(Privilege privilege,
                      File directory)
Allocate a new stub file system.

Parameters:
privilege - encapsulates privileged access to the Nachos machine.
directory - the root directory of the stub file system.
Method Detail

open

public OpenFile open(String name,
                     boolean truncate)
Description copied from interface: FileSystem
Atomically open a file, optionally creating it if it does not already exist. If the file does not already exist and create is false, returns null. If the file does not already exist and create is true, creates the file with zero length. If the file already exists, opens the file without changing it in any way.

Specified by:
open in interface FileSystem
Parameters:
name - the name of the file to open.
truncate - true to create the file if it does not already exist.
Returns:
an OpenFile representing a new instance of the opened file, or null if the file could not be opened.

remove

public boolean remove(String name)
Description copied from interface: FileSystem
Atomically remove an existing file. After a file is removed, it cannot be opened until it is created again with open. If the file is already open, it is up to the implementation to decide whether the file can still be accessed or if it is deleted immediately.

Specified by:
remove in interface FileSystem
Parameters:
name - the name of the file to remove.
Returns:
true if the file was successfully removed.