private void writeSubStreamsInfo(
            List<Folder> folders,
            List<Integer> numUnpackStreamsInFolders,
            List<Long> unpackSizes,
            List<Boolean> digestsDefined,
            List<Integer> digests) throws IOException {
        writeByte((byte) Header.NID.kSubStreamsInfo);

        for (int i = 0; i < numUnpackStreamsInFolders.size(); i++) {
            if (numUnpackStreamsInFolders.get(i) != 1) {
                writeByte((byte) Header.NID.kNumUnPackStream);
                for (i = 0; i < numUnpackStreamsInFolders.size(); i++)
                    writeNumber(numUnpackStreamsInFolders.get(i));
                break;
            }
        }


        boolean needFlag = true;
        int index = 0;
        for (Integer numUnpackStreamsInFolder : numUnpackStreamsInFolders)
            for (int j = 0; j < numUnpackStreamsInFolder; j++) {
                if (j + 1 != numUnpackStreamsInFolder) {
                    if (needFlag)
                        writeByte((byte) Header.NID.kSize);
                    needFlag = false;
                    writeNumber(unpackSizes.get(index));
                }
                index++;
            }

        List<Boolean> digestsDefined2 = new ArrayList<>();
        List<Integer> digests2 = new ArrayList<>();

        int digestIndex = 0;
        for (int i = 0; i < folders.size(); i++) {
            int numSubStreams = numUnpackStreamsInFolders.get(i);
            for (int j = 0; j < numSubStreams; j++, digestIndex++) {
                digestsDefined2.add(digestsDefined.get(digestIndex));
                digests2.add(digests.get(digestIndex));
            }
        }
        writeHashDigests(digestsDefined2, digests2);
        writeByte((byte) Header.NID.kEnd);
    }