From e0441a5bfb29083a532307ba2b1fd6d6d13944ba Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Sat, 28 Jun 2008 13:29:13 +0000 Subject: Import GNU Classpath (classpath-0_97_2-release). libjava/ 2008-06-28 Matthias Klose Import GNU Classpath (classpath-0_97_2-release). * Regenerate class and header files. * Regenerate auto* files. * gcj/javaprims.h: Define jobjectRefType. * jni.cc (_Jv_JNI_GetObjectRefType): New (stub only). (_Jv_JNIFunctions): Initialize GetObjectRefType. * gnu/classpath/jdwp/VMVirtualMachine.java, java/security/VMSecureRandom.java: Merge from classpath. * HACKING: Fix typo. * ChangeLog-2007: New file. * configure.ac: Set JAVAC, pass --disable-regen-headers to classpath. libjava/classpath/ 2008-06-28 Matthias Klose * m4/ac_prog_javac.m4: Disable check for JAVAC, when not configured with --enable-java-maintainer-mode. * aclocal.m4, configure: Regenerate. * native/jni/gstreamer-peer/Makefile.am: Do not link with libclasspathnative. * native/jni/gstreamer-peer/Makefile.in: Regenerate. * tools/Makefile.am, lib/Makefile.am: Use JAVAC for setting JCOMPILER, drop flags not understood by gcj. From-SVN: r137223 --- libjava/classpath/java/io/File.java | 67 +++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'libjava/classpath/java/io/File.java') diff --git a/libjava/classpath/java/io/File.java b/libjava/classpath/java/io/File.java index f34b4dd..cd11163 100644 --- a/libjava/classpath/java/io/File.java +++ b/libjava/classpath/java/io/File.java @@ -1293,6 +1293,73 @@ public class File implements Serializable, Comparable } /** + * Get the total space for the partition pointed by this file path, in bytes. + * + * @return the total number of bytes in this partition. + * @since 1.6 + */ + public long getTotalSpace() + { + // check security manager. + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkPermission(new RuntimePermission("getFileSystemAttributes")); + checkRead(); + + return VMFile.getTotalSpace(path); + } + + /** + * Get the free space in the partition pointed by this file path, in bytes. + * + * @return the number of free bytes in this partition. + * @since 1.6 + */ + public long getFreeSpace() + { + // check security manager. + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkPermission(new RuntimePermission("getFileSystemAttributes")); + checkRead(); + + return VMFile.getFreeSpace(path); + } + + /** + * Get the usable space in the partition pointed by this file path, in bytes. + * This is not necessarily the same as the number returned by + * {@link #getFreeSpace()}. + * + * Implementation note: Unlike the RI, on Linux and UNIX + * like systems this methods take into account the reserved space for the + * "root" user. This means that the returned results will be a little + * different if a normal user or root perform the query. + * + * Also, the bytes returned should be interpreted as an hint, and may be + * different at each call of this method or even right after the method + * returns. + * + * @return the number of usable bytes in this partition. + * @since 1.6 + */ + public long getUsableSpace() + { + // check security manager. + SecurityManager s = System.getSecurityManager(); + if (s != null) + s.checkPermission(new RuntimePermission("getFileSystemAttributes")); + checkRead(); + + // root users can use the reserved extra space + String user = System.getProperty("user.name"); + if (user != null && user.equals("root")) + return VMFile.getFreeSpace(path); + + return VMFile.getUsableSpace(path); + } + + /** * This method sets the file represented by this object to be read only. * A read only file or directory cannot be modified. Please note that * GNU systems allow read only files to be deleted if the directory it -- cgit v1.1