def test_parse_message(self):
        actual = FileEndOfFileInformation()
        data = b"\x73\x03\x10\x00\x00\x00\x00\x00"
        data = actual.unpack(data)

        assert len(actual) == 8
        assert data == b""
        assert actual['end_of_file'].get_value() == 1049459
    def test_create_message(self):
        message = FileEndOfFileInformation()
        message['end_of_file'] = 1049459

        expected = b"\x73\x03\x10\x00\x00\x00\x00\x00"
        actual = message.pack()
        assert len(message) == 8
        assert actual == expected
Example #3
0
    def truncate(self, size):
        """
        Truncate the file to at most size bytes and return the truncated size.

        Size defaults to the current file position, as returned by tell().
        The current file position is changed to the value of size.
        """
        with SMBFileTransaction(self) as transaction:
            eof_info = FileEndOfFileInformation()
            eof_info['end_of_file'] = size
            set_info(transaction, eof_info)

        self.fd.end_of_file = size
        self._flush = True
        return size