< prev index next >

src/java.base/share/classes/java/io/File.java

Print this page

        

*** 27,36 **** --- 27,37 ---- import java.net.URI; import java.net.URL; import java.net.MalformedURLException; import java.net.URISyntaxException; + import java.nio.file.FileStore; import java.nio.file.FileSystems; import java.nio.file.Path; import java.security.SecureRandom; import java.util.ArrayList; import java.util.List;
*** 1796,1806 **** /* -- Disk usage -- */ /** * Returns the size of the partition <a href="#partName">named</a> by this ! * abstract pathname. * * @return The size, in bytes, of the partition or {@code 0L} if this * abstract pathname does not name a partition * * @throws SecurityException --- 1797,1809 ---- /* -- Disk usage -- */ /** * Returns the size of the partition <a href="#partName">named</a> by this ! * abstract pathname. If the total number of bytes in the partition is ! * greater than {@link Long#MAX_VALUE}, then {@code Long.MAX_VALUE} will be ! * returned. * * @return The size, in bytes, of the partition or {@code 0L} if this * abstract pathname does not name a partition * * @throws SecurityException
*** 1808,1833 **** * {@link RuntimePermission}{@code ("getFileSystemAttributes")} * or its {@link SecurityManager#checkRead(String)} method denies * read access to the file named by this abstract pathname * * @since 1.6 */ public long getTotalSpace() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkRead(path); } if (isInvalid()) { return 0L; } ! return fs.getSpace(this, FileSystem.SPACE_TOTAL); } /** * Returns the number of unallocated bytes in the partition <a ! * href="#partName">named</a> by this abstract path name. * * <p> The returned number of unallocated bytes is a hint, but not * a guarantee, that it is possible to use most or any of these * bytes. The number of unallocated bytes is most likely to be * accurate immediately after this call. It is likely to be made --- 1811,1840 ---- * {@link RuntimePermission}{@code ("getFileSystemAttributes")} * or its {@link SecurityManager#checkRead(String)} method denies * read access to the file named by this abstract pathname * * @since 1.6 + * @see FileStore#getTotalSpace */ public long getTotalSpace() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkRead(path); } if (isInvalid()) { return 0L; } ! long space = fs.getSpace(this, FileSystem.SPACE_TOTAL); ! return space >= 0L ? space : Long.MAX_VALUE; } /** * Returns the number of unallocated bytes in the partition <a ! * href="#partName">named</a> by this abstract path name. If the ! * number of unallocated bytes in the partition is greater than ! * {@link Long#MAX_VALUE}, then {@code Long.MAX_VALUE} will be returned. * * <p> The returned number of unallocated bytes is a hint, but not * a guarantee, that it is possible to use most or any of these * bytes. The number of unallocated bytes is most likely to be * accurate immediately after this call. It is likely to be made
*** 1846,1875 **** * {@link RuntimePermission}{@code ("getFileSystemAttributes")} * or its {@link SecurityManager#checkRead(String)} method denies * read access to the file named by this abstract pathname * * @since 1.6 */ public long getFreeSpace() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkRead(path); } if (isInvalid()) { return 0L; } ! return fs.getSpace(this, FileSystem.SPACE_FREE); } /** * Returns the number of bytes available to this virtual machine on the ! * partition <a href="#partName">named</a> by this abstract pathname. When ! * possible, this method checks for write permissions and other operating ! * system restrictions and will therefore usually provide a more accurate ! * estimate of how much new data can actually be written than {@link ! * #getFreeSpace}. * * <p> The returned number of available bytes is a hint, but not a * guarantee, that it is possible to use most or any of these bytes. The * number of available bytes is most likely to be accurate immediately * after this call. It is likely to be made inaccurate by any external --- 1853,1886 ---- * {@link RuntimePermission}{@code ("getFileSystemAttributes")} * or its {@link SecurityManager#checkRead(String)} method denies * read access to the file named by this abstract pathname * * @since 1.6 + * @see FileStore#getUnallocatedSpace */ public long getFreeSpace() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkRead(path); } if (isInvalid()) { return 0L; } ! long space = fs.getSpace(this, FileSystem.SPACE_FREE); ! return space >= 0L ? space : Long.MAX_VALUE; } /** * Returns the number of bytes available to this virtual machine on the ! * partition <a href="#partName">named</a> by this abstract pathname. If ! * the number of available bytes in the partition is greater than ! * {@link Long#MAX_VALUE}, then {@code Long.MAX_VALUE} will be returned. ! * When possible, this method checks for write permissions and other ! * operating system restrictions and will therefore usually provide a more ! * accurate estimate of how much new data can actually be written than ! * {@link #getFreeSpace}. * * <p> The returned number of available bytes is a hint, but not a * guarantee, that it is possible to use most or any of these bytes. The * number of available bytes is most likely to be accurate immediately * after this call. It is likely to be made inaccurate by any external
*** 1887,1907 **** * {@link RuntimePermission}{@code ("getFileSystemAttributes")} * or its {@link SecurityManager#checkRead(String)} method denies * read access to the file named by this abstract pathname * * @since 1.6 */ public long getUsableSpace() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkRead(path); } if (isInvalid()) { return 0L; } ! return fs.getSpace(this, FileSystem.SPACE_USABLE); } /* -- Temporary files -- */ private static class TempDirectory { --- 1898,1920 ---- * {@link RuntimePermission}{@code ("getFileSystemAttributes")} * or its {@link SecurityManager#checkRead(String)} method denies * read access to the file named by this abstract pathname * * @since 1.6 + * @see FileStore#getUsableSpace */ public long getUsableSpace() { SecurityManager sm = System.getSecurityManager(); if (sm != null) { sm.checkPermission(new RuntimePermission("getFileSystemAttributes")); sm.checkRead(path); } if (isInvalid()) { return 0L; } ! long space = fs.getSpace(this, FileSystem.SPACE_USABLE); ! return space >= 0L ? space : Long.MAX_VALUE; } /* -- Temporary files -- */ private static class TempDirectory {
< prev index next >