|
1 | 1 | /*
|
2 |
| - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. |
| 2 | + * Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved. |
3 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
4 | 4 | *
|
5 | 5 | * The Universal Permissive License (UPL), Version 1.0
|
@@ -435,6 +435,63 @@ default boolean isSameFile(Path path1, Path path2, LinkOption... options) throws
|
435 | 435 | return toRealPath(path1, options).equals(toRealPath(path2, options));
|
436 | 436 | }
|
437 | 437 |
|
| 438 | + /** |
| 439 | + * Returns the size, in bytes, of the file store that contains the given {@code path}. If the |
| 440 | + * file store's size exceeds {@link Long#MAX_VALUE}, {@code Long.MAX_VALUE} is returned. |
| 441 | + * |
| 442 | + * @param path the path whose file store size is to be determined |
| 443 | + * @return the size of the file store in bytes |
| 444 | + * @throws UnsupportedOperationException if the file system does not support retrieving file |
| 445 | + * store information |
| 446 | + * @throws IOException if an I/O error occurs while accessing the file store |
| 447 | + * @throws SecurityException if the {@link FileSystem} implementation denied the operation |
| 448 | + * @since 25.0.0 |
| 449 | + */ |
| 450 | + default long getTotalSpace(Path path) throws IOException { |
| 451 | + throw new UnsupportedOperationException("TotalSpace is not supported"); |
| 452 | + } |
| 453 | + |
| 454 | + /** |
| 455 | + * Returns the number of unallocated bytes in the file store that contains the given |
| 456 | + * {@code path}. The returned value represents the raw free space on the storage device, |
| 457 | + * regardless of access permissions or user quotas. If the number of unallocated bytes exceeds |
| 458 | + * {@link Long#MAX_VALUE}, {@code Long.MAX_VALUE} is returned. Note that the value may be |
| 459 | + * imprecise, as it can change at any time due to external I/O operations, including those |
| 460 | + * performed outside this virtual machine. |
| 461 | + * |
| 462 | + * @param path the path whose file store is to be queried |
| 463 | + * @return the number of unallocated bytes |
| 464 | + * @throws UnsupportedOperationException if the file system does not support retrieving file |
| 465 | + * store information |
| 466 | + * @throws IOException if an I/O error occurs while accessing the file store |
| 467 | + * @throws SecurityException if the {@link FileSystem} implementation denied the operation |
| 468 | + * @since 25.0.0 |
| 469 | + */ |
| 470 | + default long getUnallocatedSpace(Path path) throws IOException { |
| 471 | + throw new UnsupportedOperationException("UnallocatedSpace is not supported"); |
| 472 | + } |
| 473 | + |
| 474 | + /** |
| 475 | + * Returns the number of bytes available to this Java virtual machine on the file store that |
| 476 | + * contains the given {@code path}. Unlike {@link #getUnallocatedSpace(Path)}, this method |
| 477 | + * accounts for operating system-level restrictions, user quotas, and file system permissions, |
| 478 | + * and therefore may return a smaller value. If the available space exceeds |
| 479 | + * {@link Long#MAX_VALUE}, {@code Long.MAX_VALUE} is returned. Note that the returned value may |
| 480 | + * be imprecise, as it can change at any time due to external I/O activity, including operations |
| 481 | + * performed outside this virtual machine. |
| 482 | + * |
| 483 | + * @param path the path whose file store is to be queried |
| 484 | + * @return the number of usable bytes available to this Java virtual machine |
| 485 | + * @throws UnsupportedOperationException if the file system does not support retrieving file |
| 486 | + * store information |
| 487 | + * @throws IOException if an I/O error occurs while accessing the file store |
| 488 | + * @throws SecurityException if the {@link FileSystem} implementation denied the operation |
| 489 | + * @since 25.0.0 |
| 490 | + */ |
| 491 | + default long getUsableSpace(Path path) throws IOException { |
| 492 | + throw new UnsupportedOperationException("UsableSpace is not supported"); |
| 493 | + } |
| 494 | + |
438 | 495 | /**
|
439 | 496 | * Creates a {@link FileSystem} implementation based on the host Java NIO. The returned instance
|
440 | 497 | * can be used as a delegate by a decorating {@link FileSystem}.
|
|
0 commit comments