View Javadoc

1   // Win32FileSystem.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 joeq.ClassLib.sun14_win32.java.io;
5   
6   import joeq.Memory.HeapAddress;
7   import joeq.Runtime.SystemInterface;
8   
9   /*
10   * @author  John Whaley <jwhaley@alum.mit.edu>
11   * @version $Id: Win32FileSystem.java 1456 2004-03-09 22:01:46Z jwhaley $
12   */
13  public abstract class Win32FileSystem {
14  
15      public native java.lang.String canonicalize(java.lang.String s) throws java.io.IOException;
16      public native int getBooleanAttributes(java.io.File f);
17      public native boolean checkAccess(java.io.File f, boolean b);
18      public native long getLastModifiedTime(java.io.File f);
19      public native long getLength(java.io.File f);
20      public native boolean createFileExclusively(java.lang.String s) throws java.io.IOException;
21      public native boolean delete(java.io.File f);
22      public synchronized native boolean deleteOnExit(java.io.File f);
23      public native java.lang.String[] list(java.io.File f);
24      public native boolean createDirectory(java.io.File f);
25      public native boolean rename(java.io.File f1, java.io.File f2);
26      public native boolean setLastModifiedTime(java.io.File f, long t);
27      public native boolean setReadOnly(java.io.File f);
28      
29      // gets the current directory on the named drive.
30      String getDriveDirectory(int i) {
31          byte[] b = new byte[256];
32          int result = SystemInterface.fs_getdcwd(i, b);
33          if (result == 0) throw new InternalError();
34          String res = SystemInterface.fromCString(HeapAddress.addressOf(b));
35          // skip "C:"
36          if (res.charAt(1) == ':') return res.substring(2);
37          else return res;
38      }
39      
40      
41  }