path needs to be a bytes array for python3. fix the struct.pack by using the bytes directly.

This commit is contained in:
Kalamatee 2020-02-25 20:37:35 +00:00 committed by deadwood
parent 719be8c1de
commit a0f63db997
1 changed files with 2 additions and 3 deletions

View File

@ -4,7 +4,6 @@
import os, sys, struct
from stat import ST_SIZE
PKG_PREFIX = b'PKG'
PKG_VERSION = 1
PKG_HEADER_FORMAT = '3cB'
@ -35,7 +34,7 @@ def writeHeader( file, version ):
file.write(
struct.pack(
PKG_HEADER_FORMAT,
PKG_PREFIX[0], PKG_PREFIX[1], PKG_PREFIX[2], version
b'P', b'K', b'G', version
)
)
@ -71,7 +70,7 @@ def readFile( file ):
def writeFile( file, path, data ):
'writeFile( file, path, data ) -> None'
file.write( struct.pack( "!I" + str( ( len( path ) + 4 ) & ~3 ) + "sI", -1 + ( ( len( path ) + 4 ) & ~3 ), path, len( data ) ) )
file.write( struct.pack( "!I" + str( ( len( path ) + 4 ) & ~3 ) + "sI", -1 + ( ( len( path ) + 4 ) & ~3 ), bytes(path, "iso-8859-1"), len( data ) ) )
file.write( data )