aboutsummaryrefslogtreecommitdiff
path: root/libjava/classpath/java/io/File.java
diff options
context:
space:
mode:
authorMatthias Klose <doko@gcc.gnu.org>2008-06-28 13:29:13 +0000
committerMatthias Klose <doko@gcc.gnu.org>2008-06-28 13:29:13 +0000
commite0441a5bfb29083a532307ba2b1fd6d6d13944ba (patch)
tree602cd7aa7c947386134690d8e0f6b53abcdeacb9 /libjava/classpath/java/io/File.java
parent15c151967dd1cde61b79d26374f608f63a29d411 (diff)
downloadgcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.zip
gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.gz
gcc-e0441a5bfb29083a532307ba2b1fd6d6d13944ba.tar.bz2
Import GNU Classpath (classpath-0_97_2-release).
libjava/ 2008-06-28 Matthias Klose <doko@ubuntu.com> 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 <doko@ubuntu.com> * 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
Diffstat (limited to 'libjava/classpath/java/io/File.java')
-rw-r--r--libjava/classpath/java/io/File.java67
1 files changed, 67 insertions, 0 deletions
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<File>
}
/**
+ * 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()}.
+ *
+ * <strong>Implementation note</strong>: 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