use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testLastModified.
@Test
public void testLastModified() throws IOException, NumericException {
try (Path path = new Path()) {
File f = temporaryFolder.newFile();
Assert.assertTrue(Files.touch(path.of(f.getAbsolutePath()).$()));
long t = DateFormatUtils.parseDateTime("2015-10-17T10:00:00.000Z");
Assert.assertTrue(Files.setLastModified(path, t));
Assert.assertEquals(t, Files.getLastModified(path));
}
}
use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testListDir.
@Test
public void testListDir() {
String temp = temporaryFolder.getRoot().getAbsolutePath();
ObjList<String> names = new ObjList<>();
try (Path path = new Path().of(temp).$()) {
try (Path cp = new Path()) {
Assert.assertTrue(Files.touch(cp.of(temp).concat("a.txt").$()));
NativeLPSZ name = new NativeLPSZ();
long pFind = Files.findFirst(path);
Assert.assertTrue(pFind != 0);
try {
do {
names.add(name.of(Files.findName(pFind)).toString());
} while (Files.findNext(pFind) > 0);
} finally {
Files.findClose(pFind);
}
}
}
names.sort(Chars::compare);
Assert.assertEquals("[.,..,a.txt]", names.toString());
}
use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testTruncate.
@Test
public void testTruncate() throws Exception {
File temp = temporaryFolder.newFile();
Files.writeStringToFile(temp, "abcde");
try (Path path = new Path().of(temp.getAbsolutePath()).$()) {
Assert.assertTrue(Files.exists(path));
Assert.assertEquals(5, Files.length(path));
long fd = Files.openRW(path);
try {
Files.truncate(fd, 3);
Assert.assertEquals(3, Files.length(path));
Files.truncate(fd, 0);
Assert.assertEquals(0, Files.length(path));
} finally {
Files.close(fd);
}
}
}
use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testDeleteOpenFile.
@Test
public void testDeleteOpenFile() throws Exception {
try (Path path = new Path()) {
File f = temporaryFolder.newFile();
long fd = Files.openRW(path.of(f.getAbsolutePath()).$());
Assert.assertTrue(Files.exists(fd));
Assert.assertTrue(Files.remove(path));
Assert.assertFalse(Files.exists(fd));
Files.close(fd);
}
}
use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class FilesTest method testListNonExistingDir.
@Test
public void testListNonExistingDir() {
String temp = temporaryFolder.getRoot().getAbsolutePath();
try (Path path = new Path().of(temp).concat("xyz")) {
long pFind = Files.findFirst(path);
Assert.assertTrue(pFind == 0);
}
}
Aggregations