From 0a636e2295f230e9954059700df5a0aa7772f1b9 Mon Sep 17 00:00:00 2001 From: Aurelien Aptel Date: Sat, 6 Oct 2018 10:53:53 +0200 Subject: [PATCH] remove old backup file --- cpioarchive.py.bak | 180 --------------------------------------------- 1 file changed, 180 deletions(-) delete mode 100644 cpioarchive.py.bak diff --git a/cpioarchive.py.bak b/cpioarchive.py.bak deleted file mode 100644 index 081253a..0000000 --- a/cpioarchive.py.bak +++ /dev/null @@ -1,180 +0,0 @@ -""" cpioarchive: Support for cpio archives -Copyright (C) 2006 Ignacio Vazquez-Abrams """ - -""" This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ - -import atexit - -def version(): - """Returns the version number of the module.""" - return '0.1' - -class CpioError(Exception): - """Exception class for cpioarchive exceptions""" - pass - -class CpioEntry(object): - """Information about a single file in a cpio archive. Provides a file-like -interface for interacting with the entry.""" - def __init__(self, hdr, cpio, offset): - """Create a new CpioEntry instance. Internal use only.""" - if len(hdr)<110: - raise CpioError('cpio header too short') - if not hdr.startswith('070701'): - raise CpioError('cpio header invalid') - self.inode=int(hdr[6:14], 16) - self.mode=int(hdr[14:22], 16) - self.uid=int(hdr[22:30], 16) - self.gid=int(hdr[30:38], 16) - self.nlinks=int(hdr[38:46], 16) - self.mtime=int(hdr[46:54], 16) - self.size=int(hdr[54:62], 16) - """Size of the file stored in the entry.""" - self.devmajor=int(hdr[62:70], 16) - self.devminor=int(hdr[70:78], 16) - self.rdevmajor=int(hdr[78:86], 16) - self.rdevminor=int(hdr[86:94], 16) - namesize=int(hdr[94:102], 16) - self.checksum=int(hdr[102:110], 16) - if len(hdr)<110+namesize: - raise CpioError('cpio header too short') - self.name=hdr[110:110+namesize-1] - """Name of the file stored in the entry.""" - self.datastart=offset+110+namesize - self.datastart+=(4-(self.datastart%4))%4 - self.curoffset=0 - self.cpio=cpio - self.closed=False - - def close(self): - """Close this cpio entry. Further calls to methods will raise an -exception.""" - self.closed=True - - def flush(self): - """Flush the entry (no-op).""" - pass - - def read(self, size=None): - """Read data from the entry. - -Keyword arguments: -size -- Number of bytes to read (default: whole entry) -""" - if self.closed: - raise ValueError('read operation on closed file') - self.cpio.file.seek(self.datastart+self.curoffset, 0) - if size and sizelen(self._infos): - raise StopIteration() - ret=self._infos[self._ptr] - self._ptr+=1 - return ret - - def __iter__(self): - return iter(self._infos) - - def _readfile(self, name): - self._readobj(file(name, 'rb')) - - def _readobj(self, fileobj): - self.file=fileobj - start=self.file.tell() - istart=self.file.tell() - text=self.file.read(110) - print(text) - while text: - namelen=int(text[94:102], 16) - text+=self.file.read(namelen) - ce=CpioEntry(text, self, istart) - if not ce.name=="TRAILER!!!": - self._infos.append(ce) - else: - return - self.file.seek((4-(self.file.tell()-istart)%4)%4, 1) - self.file.seek(self._infos[-1].size, 1) - self.file.seek((4-(self.file.tell()-istart)%4)%4, 1) - - istart=self.file.tell() - text=self.file.read(110) - else: - raise CpioError('premature end of headers')