private void add(TarArchiveEntry tarArchiveEntry) throws IOException {
      if (names.contains(tarArchiveEntry.getName())) {
        return;
      }

      // Adds all directories along extraction paths to explicitly set permissions for those
      // directories.
      Path namePath = Paths.get(tarArchiveEntry.getName());
      if (namePath.getParent() != namePath.getRoot()) {
        Path tarArchiveParentDir = Verify.verifyNotNull(namePath.getParent());
        TarArchiveEntry dir = new TarArchiveEntry(DIRECTORY_FILE, tarArchiveParentDir.toString());
        dir.setUserId(0);
        dir.setGroupId(0);
        dir.setUserName("");
        dir.setGroupName("");
        clearTimeHeaders(dir, FileEntriesLayer.DEFAULT_MODIFICATION_TIME);
        add(dir);
      }

      entries.add(tarArchiveEntry);
      names.add(tarArchiveEntry.getName());
    }
Adds a {@link TarArchiveEntry} if its extraction path does not exist yet. Also adds all of
the parent directories on the extraction path, if the parent does not exist. Parent will have
modification time set to {@link FileEntriesLayer#DEFAULT_MODIFICATION_TIME}.

@param tarArchiveEntry the {@link TarArchiveEntry}
@throws IOException if an I/O error occurs
jib-core/src/main/java/com/google/cloud/tools/jib/image/ReproducibleLayerBuilder.java