Close issue #54 by adding a read1 method to the MagicKeyFile class

This commit is contained in:
2016-05-21 12:24:48 +02:00
parent 5a78157112
commit cca0dbb46b
2 changed files with 9 additions and 2 deletions

View File

@ -9,6 +9,7 @@ cdef class MagicKeyFile:
cdef int pos
cpdef bytes read(self,int size=?)
cpdef bytes read1(self,int size=?)
cpdef int tell(self)

View File

@ -39,6 +39,9 @@ cdef class MagicKeyFile:
cpdef bytes read(self,int size=-1):
cdef bytes r
print(self.keylength)
print(size)
if self.pos < self.keylength:
if size > (self.keylength - self.pos):
size = size - self.keylength + self.pos
@ -54,14 +57,17 @@ cdef class MagicKeyFile:
r = self.binary.read(size)
return r
cpdef bytes read1(self,int size=-1):
return self.read(size)
cpdef int tell(self):
cdef int p
if self.pos < self.keylength:
p = self.pos
else:
p = self.tell()
p = self.binary.tell()
return p