org.jikesrvm.runtime
Class FileSystem

java.lang.Object
  extended by org.jikesrvm.runtime.FileSystem

public class FileSystem
extends Object

Interface to filesystem of underlying operating system. Historically this has provided a blocking IO abstraction on top of non-blocking IO, which was necessary for green threads. The current code contains only abstractions for dealing with things like file status.


Field Summary
static int ACCESS_F_OK
           
static int ACCESS_R_OK
           
static int ACCESS_W_OK
           
static int ACCESS_X_OK
           
static int OPEN_APPEND
           
static int OPEN_MODIFY
           
static int OPEN_READ
           
static int OPEN_WRITE
           
static int SEEK_CUR
           
static int SEEK_END
           
static int SEEK_SET
           
static int STAT_EXISTS
           
static int STAT_IS_DIRECTORY
           
static int STAT_IS_FILE
           
static int STAT_IS_READABLE
           
static int STAT_IS_WRITABLE
           
static int STAT_LAST_MODIFIED
           
static int STAT_LENGTH
           
 
Constructor Summary
FileSystem()
           
 
Method Summary
static int access(String fileName, int kind)
          Get user's perms for a file.
static int bytesAvailable(int fd)
           
static void initializeStandardStreams()
          Called from VM.boot to set up java.lang.System.in, java.lang.System.out, and java.lang.System.err
static int readByte(int fd)
          Read single byte from file.
static int readBytes(int fd, byte[] buf, int off, int cnt)
          Read multiple bytes.
static int stat(String fileName, int kind)
          Get file status.
static boolean sync(int fd)
           
static int writeByte(int fd, int b)
          Write single byte to file
static int writeBytes(int fd, byte[] buf, int off, int cnt)
          Write multiple bytes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_READ

public static final int OPEN_READ
See Also:
Constant Field Values

OPEN_WRITE

public static final int OPEN_WRITE
See Also:
Constant Field Values

OPEN_MODIFY

public static final int OPEN_MODIFY
See Also:
Constant Field Values

OPEN_APPEND

public static final int OPEN_APPEND
See Also:
Constant Field Values

SEEK_SET

public static final int SEEK_SET
See Also:
Constant Field Values

SEEK_CUR

public static final int SEEK_CUR
See Also:
Constant Field Values

SEEK_END

public static final int SEEK_END
See Also:
Constant Field Values

STAT_EXISTS

public static final int STAT_EXISTS
See Also:
Constant Field Values

STAT_IS_FILE

public static final int STAT_IS_FILE
See Also:
Constant Field Values

STAT_IS_DIRECTORY

public static final int STAT_IS_DIRECTORY
See Also:
Constant Field Values

STAT_IS_READABLE

public static final int STAT_IS_READABLE
See Also:
Constant Field Values

STAT_IS_WRITABLE

public static final int STAT_IS_WRITABLE
See Also:
Constant Field Values

STAT_LAST_MODIFIED

public static final int STAT_LAST_MODIFIED
See Also:
Constant Field Values

STAT_LENGTH

public static final int STAT_LENGTH
See Also:
Constant Field Values

ACCESS_F_OK

public static final int ACCESS_F_OK
See Also:
Constant Field Values

ACCESS_R_OK

public static final int ACCESS_R_OK
See Also:
Constant Field Values

ACCESS_W_OK

public static final int ACCESS_W_OK
See Also:
Constant Field Values

ACCESS_X_OK

public static final int ACCESS_X_OK
See Also:
Constant Field Values
Constructor Detail

FileSystem

public FileSystem()
Method Detail

stat

public static int stat(String fileName,
                       int kind)
Get file status.

Parameters:
fileName - file name
kind - kind of info desired (one of STAT_XXX, above)
Returns:
desired info (-1 -> error) The boolean ones return 0 in case of non-true, 1 in case of true status.

access

public static int access(String fileName,
                         int kind)
Get user's perms for a file.

Parameters:
fileName - file name
kind - kind of access perm(s) to check for (ACCESS_W_OK,...)
Returns:
0 if access ok (-1 -> error)

readByte

public static int readByte(int fd)
Read single byte from file.

Parameters:
fd - file descriptor
Returns:
byte that was read (< -2: i/o error, -2: timeout, -1: eof, >= 0: data)

writeByte

public static int writeByte(int fd,
                            int b)
Write single byte to file

Parameters:
fd - file descriptor
b - byte to be written
Returns:
-2: i/o error, -1: timeout, 0: ok

readBytes

public static int readBytes(int fd,
                            byte[] buf,
                            int off,
                            int cnt)
Read multiple bytes.

Parameters:
buf - a pinned byte array to read into
Returns:
-2: i/o error, -1: timeout, >=0: number of bytes read

writeBytes

public static int writeBytes(int fd,
                             byte[] buf,
                             int off,
                             int cnt)
Write multiple bytes.

Parameters:
buf - a pinned byte array to write from
Returns:
-2: i/o error, -1: timeout, >=0: number of bytes written

sync

public static boolean sync(int fd)

bytesAvailable

public static int bytesAvailable(int fd)

initializeStandardStreams

public static void initializeStandardStreams()
Called from VM.boot to set up java.lang.System.in, java.lang.System.out, and java.lang.System.err