public static boolean hasFreeSpace(final Path path, final long size)
    {
        final long freeSpace = path.toFile().getFreeSpace();

        if (freeSpace == 0L && IS_WINDOWS) {
            // On Windows, SUBST'ed drives report 0L from getFreeSpace().
            // The API doc says "The number of unallocated bytes on the partition or 0L if the abstract pathname does not name a partition."
            // There is no straightforward fix for this and it seems a fix is included in Java 9.
            // One alternative is to launch and parse a DIR command and look at the reported free space.
            // This is a temporary fix to get the CI tests going which relies on SUBST'ed drives to manage long paths.
            logger.warn("Cannot retrieve free space on " +  path.toString() +  ". This is probably a SUBST'ed drive.");
            return true;
        }

        return freeSpace >= size;
    }
@Test
    public void falseIfNotEnoughSpace() throws Exception {
        MatcherAssert.assertThat(
                FsUtil.hasFreeSpace(temp.newFolder().toPath().toAbsolutePath(), Long.MAX_VALUE),
                CoreMatchers.is(false)
        );
    }