Legacy piece formats
For developers, and for anyone who has pieces from an older program.
GSplit 4 writes only the V4 format. It reads the sets made by GSplit 3.x, GSplit 2.0, GSplit 1.x, and sets that have no metadata at all, such as those of HJSplit, 7-Zip and GNU split. GUnite 4 and gunitec read the same formats. GUnite 3 does not read V4.
How GSplit 4 recognises a set
Section titled “How GSplit 4 recognises a set”You can give GSplit 4 any piece of a set. It tries the formats in this order and takes the first that matches.
- V4: the last 32 bytes of the piece are a valid locator. See Piece format V4.
- GSplit 2.0 to 3.x, first piece: a trailer whose tag is
GSPLIT, 1259 bytes long (or 1255 bytes for GSplit 2.0 BETA), at the end of the file. - GSplit 2.0 to 3.x, piece 2 to n: a 647-byte trailer with the tag
GSPLITat the end of the file. GSplit 4 then looks for piece 1 by replacing the piece number in the file name (003or3) by001or1. - GSplit 1.x, first piece: a header with the tag
GDGat the start of the file. - GSplit 1.x, piece 2 to n: a header with the tag
GDGat the start of the file, after a file name field. Piece 1 is found as in step 3. - Raw set: no metadata; the file names form a numbered sequence.
If a piece has lost its metadata but its neighbours in a numbered sequence still have it, GSplit 4 reports a damaged GSplit set instead of treating the pieces as a raw set. Otherwise the trailers of the other pieces would end up in the result unchecked.
All names read from these formats are untrusted. GSplit 4 keeps only the part after the last / or \, replaces characters that Windows refuses, and falls back to united for an empty name, ., .., a name with control characters, or a Windows device name. Each change is logged as a warning.
GSplit 2.0 to 3.x trailer
Section titled “GSplit 2.0 to 3.x trailer”The trailer is at the end of each piece. The data of a piece are the PieceSize bytes before the trailer. In pieces 2 to n, repeated header lines or a byte order mark may come before the data; they are skipped.
Conventions of this format, which was written by Delphi programs:
- Integers are little-endian and stored without padding.
- A
shortstring[N]takes N + 1 bytes: one length byte, then up to N characters, then unused bytes up to the full size. The text is Windows-1252 in sets made by GSplit 3. Early GSplit 4 builds wrote UTF-8; GSplit 4 reads text that is not valid UTF-8 as Windows-1252. TDateTimeis an 8-byte IEEE double: days since 30 December 1899, the fraction being the time of day.FileDateandFileCreationDateare DOS packed dates: the low 16 bits are the time (hour in bits 11 to 15, minute in bits 5 to 10, seconds divided by 2 in bits 0 to 4) and the high 16 bits are the date (years since 1980 in bits 9 to 15, month in bits 5 to 8, day in bits 0 to 4).
First piece trailer
Section titled “First piece trailer”1259 bytes. Offsets are counted from the start of the trailer.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 7 | Header | shortstring[6], the tag GSPLIT. |
| 7 | 2 | Version | u16. 30010 for GSplit 3.x, 20001 for GSplit 2.0 with creation date, 20000 for GSplit 2.0 BETA. |
| 9 | 256 | Filename | shortstring[255], name of the original file. |
| 265 | 4 | FileDate | i32, DOS packed modification date of the original. |
| 269 | 8 | FileSize | i64, size of the original. |
| 277 | 4 | FileAttr | i32, file attributes. |
| 281 | 4 | FileCRC | u32, CRC-32 register after the whole file, see CRC registers. |
| 285 | 4 | NumberofPieces | u32, number of pieces in the set. |
| 289 | 1 | SpannedSet | u8, 1 for a spanned set. |
| 290 | 101 | Titre | shortstring[100], title. |
| 391 | 76 | Auteur | shortstring[75], author. |
| 467 | 256 | Desc | shortstring[255], description. |
| 723 | 8 | DateTime | TDateTime, when the set was made. |
| 731 | 256 | IDSet | shortstring[255], unique id of the set (free text). |
| 987 | 256 | Mask | shortstring[255], naming mask of the pieces. |
| 1243 | 8 | PieceSize | i64, number of data bytes in this piece. |
| 1251 | 4 | LastCRC | u32, CRC-32 register after the data of this piece. |
| 1255 | 4 | FileCreationDate | i32, DOS packed creation date. Absent in GSplit 2.0 BETA. |
The GSplit 2.0 BETA trailer has 1255 bytes: the same fields without FileCreationDate. GSplit 4 reads a creation date only when the trailer has 1259 bytes and Version is 20001 or more.
Other pieces trailer
Section titled “Other pieces trailer”647 bytes at the end of each piece from 2 to n.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 7 | Header | shortstring[6], the tag GSPLIT. |
| 7 | 2 | Version | u16, as above. |
| 9 | 256 | Filename | shortstring[255], name of the original file. |
| 265 | 101 | Titre | shortstring[100], title. |
| 366 | 256 | IDSet | shortstring[255], unique id of the set. |
| 622 | 8 | PieceSize | i64, number of data bytes in this piece. |
| 630 | 8 | OriginalOffset | i64, offset of the data in the original file. |
| 638 | 4 | LastCRC | u32, CRC-32 register after the data of this piece. |
| 642 | 4 | PieceNumber | u32, number of this piece, starting at 1. |
| 646 | 1 | FinalPiece | u8, 1 for the last piece. It is not set when the data fills the last piece exactly. |
A piece 2 to n belongs to the set when its tag is GSPLIT, its title and IDSet match those of piece 1 (the title without regard to case) and its PieceNumber is the expected number.
CRC registers
Section titled “CRC registers”FileCRC and LastCRC hold the raw state of the CRC-32 calculation: the register starts at FFFFFFFF, takes each data byte through the table of the polynomial EDB88320, and is stored without the final inversion. The standard CRC-32 of the file is the bitwise complement of FileCRC. GSplit 4 does the same calculation on reading and compares registers, so that these files stay readable byte for byte. GSplit 4 does not write these fields; V4 stores standard CRC-32 values only.
GSplit 1.x header
Section titled “GSplit 1.x header”GSplit 1.x puts a header at the start of each piece. The data follow the header: in piece 1 the PieceSize bytes after the 986-byte header, in the other pieces the PieceSize bytes after the 638-byte header. Integers are little-endian, strings are shortstring as above.
First piece header
Section titled “First piece header”986 bytes at offset 0.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 4 | Header | shortstring[3], the tag GDG. |
| 4 | 256 | Filename | shortstring[255], name of the original file. |
| 260 | 4 | FileDate | i32, DOS packed date of the original. |
| 264 | 4 | FileCRC | i32, CRC-32 of the file. Used when not 0. |
| 268 | 8 | FileSize | i64, size of the original. |
| 276 | 4 | FileAttr | i32, file attributes. |
| 280 | 101 | Titre | shortstring[100], title. |
| 381 | 76 | Auteur | shortstring[75], author. |
| 457 | 256 | IDSet | shortstring[255], unique id of the set. |
| 713 | 256 | Mask | shortstring[255], naming mask of the pieces. |
| 969 | 4 | NumberofPieces | i32, number of pieces. |
| 973 | 4 | Version | i32, version of the program that made the set. |
| 977 | 8 | PieceSize | i64, number of data bytes in this piece. |
| 985 | 1 | SpannedSet | u8, 1 for a spanned set, 0 for pieces of a fixed size. |
Other pieces header
Section titled “Other pieces header”638 bytes at offset 0. The name comes first, so the tag is not at the start of the file.
| Offset | Size | Field | Meaning |
|---|---|---|---|
| 0 | 256 | Filename | shortstring[255], name of the original file. |
| 256 | 4 | Header | shortstring[3], the tag GDG. |
| 260 | 101 | Titre | shortstring[100], title. |
| 361 | 256 | IDSet | shortstring[255], unique id of the set. |
| 617 | 4 | NumberofPieces | i32, number of pieces. |
| 621 | 4 | PieceNumber | i32, number of this piece. GSplit 4 compares its absolute value with the expected number. |
| 625 | 4 | Version | i32, version of the program. |
| 629 | 8 | PieceSize | i64, number of data bytes in this piece. |
| 637 | 1 | FinalPiece | u8, 1 for the last piece. |
A piece belongs to the set when its tag is GDG, and its title and IDSet match those of piece 1. GSplit 4 checks no CRC per piece in these sets; the CRC-32 of the file is checked only when FileCRC is not 0.
Raw sets without metadata
Section titled “Raw sets without metadata”A raw set is a plain cut of the file: the pieces, joined in order, give the original. Nothing inside a piece identifies it, so GSplit 4 relies on the file names and on an optional checksum file.
How the pieces are found
Section titled “How the pieces are found”GSplit 4 looks for a sequence token at the end of the name of the piece you give it, and collects the consecutive pieces around it:
- A number of two or more digits at the end of the name:
report.pdf.001,.002, and so on. This is how HJSplit and 7-Zip (archive.7z.001) name their pieces. A leading zero means the number is padded to a fixed width. - Two or more letters at the end of the name:
xaa,xab,xac, as written by the GNU commandsplitby default. Withsplit -d, the namesx00,x01are numbers. - A number of one or more digits at the end of the name without its extension:
disk1.gsd,disk2.gsd. This is the form of GSplit without piece headers.
The pieces found must be consecutive and at least two. The first of the run is piece 1, in the order of the sequence; the run stops at the first missing name. If a piece exists just beyond a gap (one of the next four numbers after the missing one), GSplit 4 warns that the set stops early and names the missing piece and the one that exists.
The name of the result is the part of the name before the token, without the separator before it (., _, - or space), then the extension that followed the token if any: report.pdf.001 gives report.pdf, archive.7z.001 gives archive.7z. A checksum file can give a better name, see below.
Checks of a raw set
Section titled “Checks of a raw set”A raw set holds no checksum, so GSplit 4 looks for one next to the pieces, in this order:
- A SHA-256 manifest,
<name>.sha256, where<name>is the output name or the piece name without its token. If neither exists, GSplit 4 reads up to 20.sha256files of the folder. A manifest counts only when it has a line for piece 1. The format is that ofsha256sum, described in Piece format V4. The result is checked against the line of the original file. The manifest also gives the name of the result. A manifest is the stronger check: when one is found, a.crcfile is ignored. - A Total Commander
.crcfile,<name>.crcin the same way. Its format is given below. GSplit 4 checks the CRC-32 of the result againstcrc32, takes the expected size fromsize, and the name of the result fromfilename.
With neither file, the set is joined without a check of the content.
Total Commander .crc file
Section titled “Total Commander .crc file”Total Commander uses this file for the pieces it splits. GSplit 4 reads it for raw sets and can write it next to the pieces it makes.
filename=report.pdfsize=1048576crc32=1A2B3C4Dfilenameis the name of the original file.sizeis its size in bytes.crc32is its standard CRC-32 in hexadecimal; GSplit 4 writes eight uppercase digits.
GSplit 4 reads the keys without regard to case, trims the values, and accepts a $ before the hexadecimal digits of crc32. The file is used only when crc32 is present. GSplit 4 writes the file with CR LF line ends.
See also
Section titled “See also”- Piece format V4: the format GSplit 4 writes.
- Unite pieces in GSplit: join a set in the program.
- I received pieces: what to do with pieces from another program.
- Piece inspector: shows the metadata of a piece in any of these formats.
