Add FileUtils.current().
MODIFY
src/changes/changes.xml
src/changes/changes.xml
@@ -172,6 +172,9 @@ The <action> type attribute can be add,update,fix,remove.
<action dev="ggregory" type="add" due-to="Gary Gregory">
Add org.apache.commons.io.input.Tailer.getDelayDuration().
</action>
+ <action dev="ggregory" type="add" due-to="Gary Gregory">
+ Add FileUtils.current().
+ </action>
<!-- UPDATE -->
<action dev="ggregory" type="add" due-to="Gary Gregory">
Update FileEntry to use FileTime instead of long for file time stamps.

MODIFY
src/main/java/org/apache/commons/io/FileUtils.java
src/main/java/org/apache/commons/io/FileUtils.java
@@ -1115,6 +1115,17 @@ public static File createParentDirectories(final File file) throws IOException {
return mkdirs(getParentFile(file));
}
+ /**
+ * Gets the current directory.
+ *
+ * @return the current directory.
+ *
+ * @since 2.12.0
+ */
+ public static File current() {
+ return PathUtils.current().toFile();
+ }
+
/**
* Decodes the specified URL as per RFC 3986, i.e. transforms
* percent-encoded octets to characters by decoding with the UTF-8 character
@@ -3601,4 +3612,5 @@ public static void writeStringToFile(final File file, final String data, final S
public FileUtils() { //NOSONAR
}
+
}

MODIFY
src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
src/test/java/org/apache/commons/io/FileUtilsWaitForTestCase.java
import static org.junit.jupiter.api.Assertions.assertTrue;
-import java.io.File;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
@Test
public void testWaitFor() {
- FileUtils.waitFor(new File(""), -1);
- FileUtils.waitFor(new File(""), 2);
+ FileUtils.waitFor(FileUtils.current(), -1);
+ FileUtils.waitFor(FileUtils.current(), 2);
}
@Test
public void testWaitForInterrupted() throws InterruptedException {
final AtomicBoolean wasInterrupted = new AtomicBoolean(false);
final CountDownLatch started = new CountDownLatch(1);
- final Runnable thread = () -> {
+ final Thread thread1 = new Thread(() -> {
started.countDown();
- FileUtils.waitFor(new File(""), 2);
+ FileUtils.waitFor(FileUtils.current(), 2);
wasInterrupted.set(Thread.currentThread().isInterrupted());
- };
- final Thread thread1 = new Thread(thread);
+ });
thread1.start();
started.await();
thread1.interrupt();

Add FileUtils.current().