<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def seek(self, offset, whence=SEEK_SET):
 """ Seeks to specified `offset` position in current directory entry stream. `Whence` can be SEEK_SET - from entry's start, SEEK_CUR - from current position and SEEK_END - from entry's end. Constants are same with same stored `os` module. """

        if whence == SEEK_CUR:
            offset += self.tell()
        elif whence == SEEK_END:
            offset = self.size - offset

        self._position = offset
        self._sector_number = self.sector_start
        current = 0

        while self._sector_number != ENDOFCHAIN and \
                (current + 1) * self.sector_size < offset:
            self._sector_number = self.next_sector(self._sector_number)
            current += 1

        self._position_in_sector = offset - current * self.sector_size

        position = (self._sector_number + int(not self._is_mini)) \
            << self.sector_shift
        position += self._position_in_sector

        self.stream.seek(position)
        self._source_position = self.source.tell()
        return self.tell()