|
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,96 @@ 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 getFileStoreTotalSpace(Path path) throws IOException { |
| 451 | + throw new UnsupportedOperationException("GetFileStoreTotalSpace 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 getFileStoreUnallocatedSpace(Path path) throws IOException { |
| 471 | + throw new UnsupportedOperationException("GetFileStoreUnallocatedSpace 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 #getFileStoreUnallocatedSpace(Path)}, this |
| 477 | + * method accounts for operating system level restrictions, user quotas, and file system |
| 478 | + * permissions, 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 getFileStoreUsableSpace(Path path) throws IOException { |
| 492 | + throw new UnsupportedOperationException("GetFileStoreUsableSpace is not supported"); |
| 493 | + } |
| 494 | + |
| 495 | + /** |
| 496 | + * Returns the number of bytes per block in the file store that contains the given {@code path}. |
| 497 | + * |
| 498 | + * @param path the path whose file store is to be queried |
| 499 | + * @return the block size |
| 500 | + * @throws UnsupportedOperationException if the file system does not support retrieving file |
| 501 | + * store information |
| 502 | + * @throws IOException if an I/O error occurs while accessing the file store |
| 503 | + * @throws SecurityException if the {@link FileSystem} implementation denied the operation |
| 504 | + * @since 25.0.0 |
| 505 | + */ |
| 506 | + default long getFileStoreBlockSize(Path path) throws IOException { |
| 507 | + throw new UnsupportedOperationException("GetFileStoreBlockSize is not supported"); |
| 508 | + } |
| 509 | + |
| 510 | + /** |
| 511 | + * Determines whether the file store containing the given {@code path} is read-only. |
| 512 | + * <p> |
| 513 | + * Note that even if the file store is not read-only, individual write operations may still be |
| 514 | + * denied due to restrictions imposed by the {@link FileSystem} implementation, operating system |
| 515 | + * level policies, user quotas, or file system permissions. |
| 516 | + * |
| 517 | + * @param path the path whose file store is to be queried |
| 518 | + * @throws UnsupportedOperationException if the file system does not support retrieving file |
| 519 | + * store information |
| 520 | + * @throws IOException if an I/O error occurs while accessing the file store |
| 521 | + * @throws SecurityException if the {@link FileSystem} implementation denied the operation |
| 522 | + * @since 25.0.0 |
| 523 | + */ |
| 524 | + default boolean isFileStoreReadOnly(Path path) throws IOException { |
| 525 | + throw new UnsupportedOperationException("IsFileStoreReadOnly is not supported"); |
| 526 | + } |
| 527 | + |
438 | 528 | /**
|
439 | 529 | * Creates a {@link FileSystem} implementation based on the host Java NIO. The returned instance
|
440 | 530 | * can be used as a delegate by a decorating {@link FileSystem}.
|
|
0 commit comments