HardLink { public static void createHardLinkMult(File parentDir, String[] fileBaseNames, File linkDir) throws IOException { if (parentDir == null) { throw new IOException( "invalid arguments to createHardLinkMult: parent directory is null"); } if (linkDir == null) { throw new IOException( "invalid arguments to createHardLinkMult: link directory is null"); } if (fileBaseNames == null) { throw new IOException( "invalid arguments to createHardLinkMult: " + "filename list can be empty but not null"); } if (!linkDir.exists()) { throw new FileNotFoundException(linkDir + " not found."); } for (String name : fileBaseNames) { createLink(linkDir.toPath().resolve(name), parentDir.toPath().resolve(name)); } } HardLink(); static void createHardLink(File file, File linkName); static void createHardLinkMult(File parentDir, String[] fileBaseNames,
      File linkDir); static int getLinkCount(File fileName); final LinkStats linkStats; }
@Test public void testCreateHardLinkMult() throws IOException { String[] fileNames = src.list(); createHardLinkMult(src, fileNames, tgt_mult); assertEquals(2, getLinkCount(x1)); assertEquals(2, getLinkCount(x2)); assertEquals(2, getLinkCount(x3)); assertEquals(2, getLinkCount(x1_mult)); assertEquals(2, getLinkCount(x2_mult)); assertEquals(2, getLinkCount(x3_mult)); validateTgtMult(); appendToFile(x1_mult, str3); assertTrue(fetchFileContents(x1_mult).equals(str1 + str3)); assertTrue(fetchFileContents(x1).equals(str1 + str3)); }
@Test public void testCreateHardLinkMultEmptyList() throws IOException { String[] emptyList = {}; createHardLinkMult(src, emptyList, tgt_mult); validateSetup(); }