org.bluesock.bluemud.driver
Class FileManager

java.lang.Object
  |
  +--org.bluesock.bluemud.driver.FileManager

public class FileManager
extends java.lang.Object

The FileManager is responsible for the management of all access to disk, including reading files, writing files, providing directory listings, etc. All disk access should go through this class. TODO: Add decent error handling. At the moment, this class just dumps a stack trace and returns failure.


Constructor Summary
FileManager()
           
 
Method Summary
(package private) static boolean createDirectory(java.lang.String dirname)
          Creates a directory.
(package private) static java.lang.String[] fstatFile(java.lang.String filename)
          Returns an array of strings in this order: file name length (size) last modified Throws an IOException for almost any issues.
(package private) static boolean isDirectory(java.lang.String dirname)
          Allows you to discern if a certain path is a directory or not.
(package private) static boolean isFile(java.lang.String filename)
          Allows you to discern if a certain file is a file or not.
(package private) static java.lang.String[] listDirectory(java.lang.String dirname)
          Returns the directory contents as an array of Strings.
(package private) static java.lang.String readFile(java.lang.String filename)
          Read a file from disk and don't cache it.
(package private) static java.lang.String readFile(java.lang.String filename, boolean cachethis)
          Read a file from disk.
(package private) static boolean removeDirectory(java.lang.String dirname)
          Removes a directory.
(package private) static boolean removeFile(java.lang.String filename)
          Removes a file.
(package private) static boolean touchFile(java.lang.String filename)
          Creates a new empty file with the specified path if that file doesn't already exist.
(package private) static boolean writeFile(java.lang.String content, java.lang.String filename)
          Write a file to disk.
(package private) static boolean writeFile(java.lang.String content, java.lang.String filename, boolean append)
          Write a file to disk.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileManager

public FileManager()
Method Detail

writeFile

static boolean writeFile(java.lang.String content,
                         java.lang.String filename)
Write a file to disk.
Parameters:
content - The content to write to a file.
filename - The name of the file to write to.

writeFile

static boolean writeFile(java.lang.String content,
                         java.lang.String filename,
                         boolean append)
Write a file to disk.
Parameters:
content - The content to write to a file.
filename - The name of the file to write to.
append - Whether to append to the end of the file or just replace the file.

touchFile

static boolean touchFile(java.lang.String filename)
Creates a new empty file with the specified path if that file doesn't already exist.
Parameters:
filename - The path to the file to create.
Returns:
true if the file was created, false otherwise.

readFile

static java.lang.String readFile(java.lang.String filename)
Read a file from disk and don't cache it.
Parameters:
filename - The name of the file to read.

readFile

static java.lang.String readFile(java.lang.String filename,
                                 boolean cachethis)
Read a file from disk.
Parameters:
filename - The name of the file to read.
cachethis - True if we want to cache the file

listDirectory

static java.lang.String[] listDirectory(java.lang.String dirname)
                                 throws java.io.IOException
Returns the directory contents as an array of Strings. Throws an IOException for almost any issues.

fstatFile

static java.lang.String[] fstatFile(java.lang.String filename)
                             throws java.io.IOException
Returns an array of strings in this order: file name length (size) last modified Throws an IOException for almost any issues.

isDirectory

static boolean isDirectory(java.lang.String dirname)
                    throws java.io.IOException
Allows you to discern if a certain path is a directory or not.
Parameters:
dirname - name of the directory to query.
Returns:
boolean true if it's a directory and false if not.

isFile

static boolean isFile(java.lang.String filename)
               throws java.io.IOException
Allows you to discern if a certain file is a file or not.
Parameters:
filename - name of the file in question.
Returns:
boolean true if it is a file.

removeDirectory

static boolean removeDirectory(java.lang.String dirname)
                        throws java.io.IOException
Removes a directory.
Parameters:
dirname - name of the directory to remove.
Returns:
boolean true if it removed the directory and false if it didn't.

removeFile

static boolean removeFile(java.lang.String filename)
                   throws java.io.IOException
Removes a file.
Parameters:
filename - name of the file to re move.
Returns:
true if the file was successfully removed, false otherwise.

createDirectory

static boolean createDirectory(java.lang.String dirname)
                        throws java.io.IOException
Creates a directory.
Parameters:
dirname - name of the directory to create.
Returns:
boolean true if it made the directory and false if it didn't.


docs generated on Thu Jan 24 08:57:26 CST 2002