def from_stream(cls, stream, offset=None, byte_order=LITTLE_ENDIAN): """Creates a ``datetime`` object from a stream. :type stream: :class:`lf.dec.IStream` :param stream: A stream that contains the FILETIME structure. :type offset: ``int`` or ``None`` :param offset: The start of the FILETIME structure in the stream. :type byte_order: constant :param byte_order: The byte order to use (from :mod:`lf.dtypes`) :raises ValueError: If the FILETIME structure is invalid. :rtype: ``datetime`` :returns: The corresponding ``datetime`` object. """ if offset is not None: stream.seek(offset, SEEK_SET) # end if data = stream.read(8) if byte_order == LITTLE_ENDIAN: filetime = uint64_le.from_buffer_copy(data).value else: filetime = uint64_be.from_buffer_copy(data).value # end if return cls.from_int(filetime)
def uint64_be(self, offset=None): """Reads an unsigned 64-bit integer (big endian). :type offset: :class:`int` or :keyword:`None` :param offset: The start of the integer. :except ValueError: if :attr:`stream` (starting at :attr:`offset` is too small.) :rtype: :class:`int` :returns: The corresponding value. """ if offset is not None: self.stream.seek(offset, SEEK_SET) # end if return uint64_be.from_buffer_copy(self.stream.read(8)).value