copyDirectory (all overloads) does not maintain file
permissions
Add a test
MODIFY
src/test/java/org/apache/commons/io/FileUtilsTest.java
src/test/java/org/apache/commons/io/FileUtilsTest.java
@@ -1615,6 +1615,28 @@ public void testIO300() {
assertTrue(src.exists());
}
+ @Test
+ public void testIO575() throws IOException {
+ final Path sourceDir = Files.createTempDirectory("source-dir");
+ final String filename = "some-file";
+ final Path sourceFile = Files.createFile(sourceDir.resolve(filename));
+
+ assertEquals(SystemUtils.IS_OS_WINDOWS, sourceFile.toFile().canExecute());
+
+ sourceFile.toFile().setExecutable(true);
+
+ assertTrue(sourceFile.toFile().canExecute());
+
+ final Path destDir = Files.createTempDirectory("some-empty-destination");
+
+ FileUtils.copyDirectory(sourceDir.toFile(), destDir.toFile());
+
+ final Path destFile = destDir.resolve(filename);
+
+ assertTrue(destFile.toFile().exists());
+ assertTrue(destFile.toFile().canExecute());
+ }
+
@Test
public void testIsDirectory() throws IOException {
assertFalse(FileUtils.isDirectory(null));

[IO-575] copyDirectory (all overloads) does not maintain file (#379)

permissions

Add a test

Co-authored-by: Gary Gregory <ggregory@rocketsoftware.com>