MCPcopy Index your code
hub / github.com/questdb/questdb / testDeleteDir

Method testDeleteDir

core/src/test/java/io/questdb/test/FilesTest.java:283–317  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

281 }
282
283 @Test
284 public void testDeleteDir() throws Exception {
285 Assume.assumeFalse(Os.isWindows());
286 assertMemoryLeak(() -> {
287 File r = temporaryFolder.newFolder("to_delete");
288 Assert.assertTrue(new File(r, "a" + Files.SEPARATOR + "b" + Files.SEPARATOR + "c" + Files.SEPARATOR + "d").mkdirs());
289 Assert.assertTrue(new File(r, "d" + Files.SEPARATOR + "e" + Files.SEPARATOR + "f").mkdirs());
290 touch(new File(r, "a" + Files.SEPARATOR + "1.txt"));
291 touch(new File(r, "a" + Files.SEPARATOR + "b" + Files.SEPARATOR + "2.txt"));
292 touch(new File(r, "a" + Files.SEPARATOR + "b" + Files.SEPARATOR + "c" + Files.SEPARATOR + "3.txt"));
293 touch(new File(r, "d" + Files.SEPARATOR + "1.txt"));
294 touch(new File(r, "d" + Files.SEPARATOR + "e" + Files.SEPARATOR + "2.txt"));
295 touch(new File(r, "d" + Files.SEPARATOR + "e" + Files.SEPARATOR + "f" + Files.SEPARATOR + "3.txt"));
296
297 try (
298 Path targetPath = new Path().of(r.getAbsolutePath()).concat("d");
299 Path linkPath = new Path().of(r.getAbsolutePath()).concat("a").concat("link_to_d")
300 ) {
301 Assert.assertEquals(0, Files.softLink(targetPath.$(), linkPath.$()));
302 Assert.assertTrue(Files.isSoftLink(linkPath.$()));
303
304 targetPath.of(r.getAbsolutePath());
305 linkPath.of(r.getParentFile().getAbsolutePath()).concat("start_here");
306 Assert.assertEquals(0, Files.softLink(targetPath.$(), linkPath.$()));
307 Assert.assertTrue(Files.isSoftLink(linkPath.$()));
308
309 Assert.assertTrue(Files.rmdir(linkPath, true));
310 Assert.assertFalse(new File(linkPath.toString()).exists());
311 Assert.assertTrue(r.exists());
312 Assert.assertEquals(0L, Files.getDirSize(targetPath));
313 Assert.assertTrue(Files.rmdir(targetPath.slash(), true));
314 Assert.assertFalse(r.exists());
315 }
316 });
317 }
318
319 @Test
320 public void testDeleteOpenFile() throws Exception {

Callers

nothing calls this directly

Calls 15

isWindowsMethod · 0.95
touchMethod · 0.95
softLinkMethod · 0.95
isSoftLinkMethod · 0.95
rmdirMethod · 0.95
getDirSizeMethod · 0.95
concatMethod · 0.80
slashMethod · 0.80
mkdirsMethod · 0.65
ofMethod · 0.65
$Method · 0.65
existsMethod · 0.65

Tested by

no test coverage detected