Source code: ClassLib/sun14_win32/java/io/RandomAccessFile.java
1 // RandomAccessFile.java, created Fri Apr 5 18:36:41 2002 by joewhaley
2 // Copyright (C) 2001-3 John Whaley <jwhaley@alum.mit.edu>
3 // Licensed under the terms of the GNU LGPL; see COPYING for details.
4 package ClassLib.sun14_win32.java.io;
5
6 import Run_Time.SystemInterface;
7
8 /**
9 * RandomAccessFile
10 *
11 * @author John Whaley <jwhaley@alum.mit.edu>
12 * @version $Id: RandomAccessFile.java,v 1.6 2003/07/23 18:29:46 joewhaley Exp $
13 */
14 public class RandomAccessFile {
15
16 private FileDescriptor fd;
17
18 private static final int O_RDONLY = 1;
19 private static final int O_RDWR = 2;
20 private static final int O_SYNC = 4;
21 private static final int O_DSYNC = 8;
22
23 public void open(java.lang.String name, int mode)
24 throws java.io.FileNotFoundException {
25 int flags = SystemInterface._O_BINARY;
26 if ((mode & O_RDONLY) != 0) flags |= SystemInterface._O_RDONLY;
27 if ((mode & O_RDWR) != 0) flags |= SystemInterface._O_RDWR | SystemInterface._O_CREAT;
28 if ((mode & O_SYNC) != 0) {
29 // todo: require that every update to the file's content or metadata be
30 // written synchronously to the underlying storage device
31 }
32 if ((mode & O_DSYNC) != 0) {
33 // todo: require that every update to the file's content be written
34 // synchronously to the underlying storage device.
35 }
36 int fdnum = SystemInterface.file_open(name, flags, 0);
37 if (fdnum == -1) throw new java.io.FileNotFoundException(name);
38 this.fd.fd = fdnum;
39 }
40
41 }