DPK

From Just Solve the File Format Problem
(Difference between revisions)
Jump to: navigation, search
m (Specification)
(Sample files)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{FormatInfo
 
{{FormatInfo
 
|formattype=electronic
 
|formattype=electronic
|subcat=Archiving
+
|subcat=Game data files
 
|extensions={{ext|dpk}}
 
|extensions={{ext|dpk}}
 
}}
 
}}
 +
A '''.dpk''' file is a simple archive format without compression. The format appears to be proprietary and specific to the ''Bunny Pro. Das2'' [https://en.wikipedia.org/wiki/Visual_novel visual novel] software for Windows.
  
A '''.dpk''' file is a simple archive format without compression. The format appears to be proprietary and specific to [https://en.wikipedia.org/wiki/Visual_novel visual novel] software for Windows.
+
See also [[NAS]].
  
 
== Specification ==
 
== Specification ==
Line 11: Line 12:
 
The format comprises a '''header''' and '''payload'''.
 
The format comprises a '''header''' and '''payload'''.
  
The '''header''' includes the magic bytes "PA" followed by the ''number of entries'' (<code>short</code>) and ''total file size'' (<code>int</code>). Each file entry in the header is then designated by a null-terminated string of 16 characters (ASCII) and the ''length of the file'' (<code>int</code>)
+
The '''header''' includes the magic bytes "PA" followed by the ''number of entries'' (<code>short</code>) and ''total file size'' (<code>int</code>). Each file entry in the header is then designated by a null-padded string of 16 characters (ASCII) and the ''length of the file'' (<code>int</code>)
  
 
Files in the payload are stored in the order in which the entry appears, and can be extracted by reading the number of bytes corresponding to the ''length of the file''.
 
Files in the payload are stored in the order in which the entry appears, and can be extracted by reading the number of bytes corresponding to the ''length of the file''.
  
 
== Source ==
 
== Source ==
 +
 +
The following source can be used to extract <code>.dpk</code> files using Python.
  
 
<pre>
 
<pre>
Line 67: Line 70:
  
 
== Sample files ==
 
== Sample files ==
* http://discmaster.textfiles.com/view/6808/Corsage%20-%20Disc%201.iso/wav.dpk
+
* [https://archive.org/details/Corsage_1653931983498 Corsage] → ...Disc 1.iso → WAV.DPK
 +
* {{DexvertSamples|archive/visualNovelDPK}}

Latest revision as of 15:04, 28 December 2023

File Format
Name DPK
Ontology
Extension(s) .dpk

A .dpk file is a simple archive format without compression. The format appears to be proprietary and specific to the Bunny Pro. Das2 visual novel software for Windows.

See also NAS.

[edit] Specification

The format comprises a header and payload.

The header includes the magic bytes "PA" followed by the number of entries (short) and total file size (int). Each file entry in the header is then designated by a null-padded string of 16 characters (ASCII) and the length of the file (int)

Files in the payload are stored in the order in which the entry appears, and can be extracted by reading the number of bytes corresponding to the length of the file.

[edit] Source

The following source can be used to extract .dpk files using Python.

import struct
import argparse
import os

header_format = '2shi'
header_size = struct.calcsize(header_format)

entry_format = '16si'
entry_size = struct.calcsize(entry_format)

def unpack(fileName):
	BASE_NAME = os.path.splitext(os.path.basename(fileName))[0]

	os.mkdir(BASE_NAME)

	with open(fileName, 'rb') as f:
		[magic_bytes, file_count, package_size] = struct.unpack(header_format, f.read(header_size))

		assert magic_bytes == b'PA'
		assert file_count > 0
		assert package_size > 0

		FILES = []

		for i in range(0, file_count, 1):
			[file_name, file_size] = struct.unpack(entry_format, f.read(entry_size))
			
			FILES.append([
				file_name.decode("ascii").rstrip('\x00'),
				file_size
			])
		
		for file_name, file_size in FILES:
			file_data = bytearray(f.read(file_size))

			with open(os.path.join(BASE_NAME, file_name), 'wb') as new_file:
				new_file.write(file_data)

if __name__ == '__main__':
	parser = argparse.ArgumentParser(
                    prog = 'dpk Unpacker',
                    description = 'Unpacks .dpk packages')
	parser.add_argument('INPUT_FILE')
	args = parser.parse_args()
	
	unpack(args.INPUT_FILE)

[edit] Sample files

Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox