blob: f0b6193066c27820c67ad3fa178def9967557513 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
/*
* Copyright (C) 2008, Robin Rosenberg <robin.rosenberg@dewire.com>
* Copyright (C) 2008, Shawn O. Pearce <spearce@spearce.org> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
* https://www.eclipse.org/org/documents/edl-v10.php.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
package org.eclipse.jgit.internal.storage.file;
import java.io.IOException;
import java.io.OutputStream;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.transport.PackedObjectInfo;
import org.eclipse.jgit.util.NB;
/**
* Creates the version 1 (old style) pack table of contents files.
*
* @see BasePackIndexWriter
* @see PackIndexV1
*/
class PackIndexWriterV1 extends BasePackIndexWriter {
static boolean canStore(PackedObjectInfo oe) {
// We are limited to 4 GB per pack as offset is 32 bit unsigned int.
//
return oe.getOffset() >>> 1 < Integer.MAX_VALUE;
}
PackIndexWriterV1(final OutputStream dst) {
super(dst);
}
@Override
protected void writeImpl() throws IOException {
writeFanOutTable();
for (PackedObjectInfo oe : entries) {
if (!canStore(oe))
throw new IOException(JGitText.get().packTooLargeForIndexVersion1);
NB.encodeInt32(tmp, 0, (int) oe.getOffset());
oe.copyRawTo(tmp, 4);
out.write(tmp);
}
writeChecksumFooter();
}
}
|