TarLayoutWriter Class — spring-boot Architecture
Architecture documentation for the TarLayoutWriter class in TarLayoutWriter.java from the spring-boot codebase.
Entity Profile
Source Code
buildpack/spring-boot-buildpack-platform/src/main/java/org/springframework/boot/buildpack/platform/io/TarLayoutWriter.java lines 35–86
class TarLayoutWriter implements Layout, Closeable {
static final long NORMALIZED_MOD_TIME = TarArchive.NORMALIZED_TIME.toEpochMilli();
private final TarArchiveOutputStream outputStream;
TarLayoutWriter(OutputStream outputStream) {
this.outputStream = new TarArchiveOutputStream(outputStream);
this.outputStream.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
}
@Override
public void directory(String name, Owner owner, int mode) throws IOException {
this.outputStream.putArchiveEntry(createDirectoryEntry(name, owner, mode));
this.outputStream.closeArchiveEntry();
}
@Override
public void file(String name, Owner owner, int mode, Content content) throws IOException {
this.outputStream.putArchiveEntry(createFileEntry(name, owner, mode, content.size()));
content.writeTo(StreamUtils.nonClosing(this.outputStream));
this.outputStream.closeArchiveEntry();
}
private TarArchiveEntry createDirectoryEntry(String name, Owner owner, int mode) {
return createEntry(name, owner, TarConstants.LF_DIR, mode, 0);
}
private TarArchiveEntry createFileEntry(String name, Owner owner, int mode, int size) {
return createEntry(name, owner, TarConstants.LF_NORMAL, mode, size);
}
private TarArchiveEntry createEntry(String name, Owner owner, byte linkFlag, int mode, int size) {
TarArchiveEntry entry = new TarArchiveEntry(name, linkFlag, true);
entry.setUserId(owner.getUid());
entry.setGroupId(owner.getGid());
entry.setMode(mode);
entry.setModTime(NORMALIZED_MOD_TIME);
entry.setSize(size);
return entry;
}
void finish() throws IOException {
this.outputStream.finish();
}
@Override
public void close() throws IOException {
this.outputStream.close();
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free