use of com.github.mgramin.sqlboot.tools.files.file.File in project sql-boot by sql-boot.
the class ZippedFile method unzip.
private byte[] unzip() throws BootException {
try (ByteArrayOutputStream bytes = new ByteArrayOutputStream();
ZipOutputStream zip = new ZipOutputStream(bytes)) {
for (final File ent : this.origins) {
zip.putNextEntry(new ZipEntry(ent.name()));
zip.write(ent.content());
zip.closeEntry();
}
zip.close();
bytes.close();
return bytes.toByteArray();
} catch (final IOException exception) {
throw new BootException(exception);
}
}
use of com.github.mgramin.sqlboot.tools.files.file.File in project sql-boot by sql-boot.
the class LocalFileSystem method listFiles.
@Override
public List<File> listFiles(final String mask) {
try {
DirectoryScanner scanner = new DirectoryScanner();
scanner.setIncludes(new String[] { mask });
scanner.setBasedir(this.basedir.replace("\\", "/"));
scanner.setCaseSensitive(false);
scanner.scan();
String[] files = scanner.getIncludedFiles();
List<File> result = new ArrayList<>();
for (String file : files) {
result.add(new SimpleFile(file, FileUtils.readFileToByteArray(new java.io.File(basedir + "/" + file))));
}
return result;
} catch (IOException exception) {
throw new BootException(exception);
}
}
use of com.github.mgramin.sqlboot.tools.files.file.File in project sql-boot by sql-boot.
the class ZippedFileTest method content.
@Test
public void content() throws Exception {
File zip = new ZippedFile("test.zip", asList(new FakeFile()));
assertEquals(144, zip.content().length);
}
Aggregations