Skip to content
GSplit

Legacy piece formats

Advanced reference

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.

You can give GSplit 4 any piece of a set. It tries the formats in this order and takes the first that matches.

  1. V4: the last 32 bytes of the piece are a valid locator. See Piece format V4.
  2. 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.
  3. GSplit 2.0 to 3.x, piece 2 to n: a 647-byte trailer with the tag GSPLIT at the end of the file. GSplit 4 then looks for piece 1 by replacing the piece number in the file name (003 or 3) by 001 or 1.
  4. GSplit 1.x, first piece: a header with the tag GDG at the start of the file.
  5. GSplit 1.x, piece 2 to n: a header with the tag GDG at the start of the file, after a file name field. Piece 1 is found as in step 3.
  6. 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.

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.
  • TDateTime is an 8-byte IEEE double: days since 30 December 1899, the fraction being the time of day.
  • FileDate and FileCreationDate are 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).

1259 bytes. Offsets are counted from the start of the trailer.

OffsetSizeFieldMeaning
07Headershortstring[6], the tag GSPLIT.
72Versionu16. 30010 for GSplit 3.x, 20001 for GSplit 2.0 with creation date, 20000 for GSplit 2.0 BETA.
9256Filenameshortstring[255], name of the original file.
2654FileDatei32, DOS packed modification date of the original.
2698FileSizei64, size of the original.
2774FileAttri32, file attributes.
2814FileCRCu32, CRC-32 register after the whole file, see CRC registers.
2854NumberofPiecesu32, number of pieces in the set.
2891SpannedSetu8, 1 for a spanned set.
290101Titreshortstring[100], title.
39176Auteurshortstring[75], author.
467256Descshortstring[255], description.
7238DateTimeTDateTime, when the set was made.
731256IDSetshortstring[255], unique id of the set (free text).
987256Maskshortstring[255], naming mask of the pieces.
12438PieceSizei64, number of data bytes in this piece.
12514LastCRCu32, CRC-32 register after the data of this piece.
12554FileCreationDatei32, 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.

647 bytes at the end of each piece from 2 to n.

OffsetSizeFieldMeaning
07Headershortstring[6], the tag GSPLIT.
72Versionu16, as above.
9256Filenameshortstring[255], name of the original file.
265101Titreshortstring[100], title.
366256IDSetshortstring[255], unique id of the set.
6228PieceSizei64, number of data bytes in this piece.
6308OriginalOffseti64, offset of the data in the original file.
6384LastCRCu32, CRC-32 register after the data of this piece.
6424PieceNumberu32, number of this piece, starting at 1.
6461FinalPieceu8, 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.

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 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.

986 bytes at offset 0.

OffsetSizeFieldMeaning
04Headershortstring[3], the tag GDG.
4256Filenameshortstring[255], name of the original file.
2604FileDatei32, DOS packed date of the original.
2644FileCRCi32, CRC-32 of the file. Used when not 0.
2688FileSizei64, size of the original.
2764FileAttri32, file attributes.
280101Titreshortstring[100], title.
38176Auteurshortstring[75], author.
457256IDSetshortstring[255], unique id of the set.
713256Maskshortstring[255], naming mask of the pieces.
9694NumberofPiecesi32, number of pieces.
9734Versioni32, version of the program that made the set.
9778PieceSizei64, number of data bytes in this piece.
9851SpannedSetu8, 1 for a spanned set, 0 for pieces of a fixed size.

638 bytes at offset 0. The name comes first, so the tag is not at the start of the file.

OffsetSizeFieldMeaning
0256Filenameshortstring[255], name of the original file.
2564Headershortstring[3], the tag GDG.
260101Titreshortstring[100], title.
361256IDSetshortstring[255], unique id of the set.
6174NumberofPiecesi32, number of pieces.
6214PieceNumberi32, number of this piece. GSplit 4 compares its absolute value with the expected number.
6254Versioni32, version of the program.
6298PieceSizei64, number of data bytes in this piece.
6371FinalPieceu8, 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.

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.

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 command split by default. With split -d, the names x00, x01 are 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.

A raw set holds no checksum, so GSplit 4 looks for one next to the pieces, in this order:

  1. 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 .sha256 files of the folder. A manifest counts only when it has a line for piece 1. The format is that of sha256sum, 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 .crc file is ignored.
  2. A Total Commander .crc file, <name>.crc in the same way. Its format is given below. GSplit 4 checks the CRC-32 of the result against crc32, takes the expected size from size, and the name of the result from filename.

With neither file, the set is joined without a check of the content.

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.pdf
size=1048576
crc32=1A2B3C4D
  • filename is the name of the original file.
  • size is its size in bytes.
  • crc32 is 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.

Back to top

Screenshot