[Python-checkins] python/dist/src/Lib tarfile.py,1.13,1.14
nnorwitz at users.sourceforge.net
nnorwitz at users.sourceforge.net
Wed Jul 21 00:23:05 CEST 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16250/Lib
Modified Files:
tarfile.py
Log Message:
SF #918101, allow files >= 8 GB using GNU extension
Index: tarfile.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/tarfile.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** tarfile.py 20 Jul 2004 22:07:43 -0000 1.13
--- tarfile.py 20 Jul 2004 22:23:02 -0000 1.14
***************
*** 656,664 ****
"""
tarinfo = cls()
! tarinfo.name = nts(buf[0:100])
tarinfo.mode = int(buf[100:108], 8)
tarinfo.uid = int(buf[108:116],8)
tarinfo.gid = int(buf[116:124],8)
! tarinfo.size = long(buf[124:136], 8)
tarinfo.mtime = long(buf[136:148], 8)
tarinfo.chksum = int(buf[148:156], 8)
--- 656,674 ----
"""
tarinfo = cls()
! tarinfo.name = nts(buf[0:100])
tarinfo.mode = int(buf[100:108], 8)
tarinfo.uid = int(buf[108:116],8)
tarinfo.gid = int(buf[116:124],8)
!
! # There are two possible codings for the size field we
! # have to discriminate, see comment in tobuf() below.
! if buf[124] != chr(0200):
! tarinfo.size = long(buf[124:136], 8)
! else:
! tarinfo.size = 0L
! for i in range(11):
! tarinfo.size <<= 8
! tarinfo.size += ord(buf[125 + i])
!
tarinfo.mtime = long(buf[136:148], 8)
tarinfo.chksum = int(buf[148:156], 8)
***************
*** 690,703 ****
"""Return a tar header block as a 512 byte string.
"""
! name = self.name
# The following code was contributed by Detlef Lannert.
parts = []
for value, fieldsize in (
! (name, 100),
("%07o" % (self.mode & 07777), 8),
("%07o" % self.uid, 8),
("%07o" % self.gid, 8),
! ("%011o" % self.size, 12),
("%011o" % self.mtime, 12),
(" ", 8),
--- 700,725 ----
"""Return a tar header block as a 512 byte string.
"""
! # Prefer the size to be encoded as 11 octal ascii digits
! # which is the most portable. If the size exceeds this
! # limit (>= 8 GB), encode it as an 88-bit value which is
! # a GNU tar feature.
! if self.size <= MAXSIZE_MEMBER:
! size = "%011o" % self.size
! else:
! s = self.size
! size = ""
! for i in range(11):
! size = chr(s & 0377) + size
! s >>= 8
! size = chr(0200) + size
# The following code was contributed by Detlef Lannert.
parts = []
for value, fieldsize in (
! (self.name, 100),
("%07o" % (self.mode & 07777), 8),
("%07o" % self.uid, 8),
("%07o" % self.gid, 8),
! (size, 12),
("%011o" % self.mtime, 12),
(" ", 8),
***************
*** 1237,1241 ****
if tarinfo.size > MAXSIZE_MEMBER:
! raise ValueError, "file is too large (>8GB)"
if len(tarinfo.linkname) > LENGTH_LINK:
--- 1259,1267 ----
if tarinfo.size > MAXSIZE_MEMBER:
! if self.posix:
! raise ValueError, "file is too large (>= 8 GB)"
! else:
! self._dbg(2, "tarfile: Created GNU tar largefile header")
!
if len(tarinfo.linkname) > LENGTH_LINK:
More information about the Python-checkins
mailing list