Gets the file bytes from a remote host
(self, file, fd)
| 1552 | print(result) |
| 1553 | |
| 1554 | def _get_file(self, file, fd): |
| 1555 | """ |
| 1556 | Gets the file bytes from a remote host |
| 1557 | """ |
| 1558 | # Get pwd of the ls |
| 1559 | fpath = self.pwd / file |
| 1560 | self.smbsock.set_TID(self.current_tree) |
| 1561 | # Open file |
| 1562 | fileId = self.smbsock.create_request( |
| 1563 | self.normalize_path(fpath), |
| 1564 | type="file", |
| 1565 | extra_create_options=[ |
| 1566 | "FILE_SEQUENTIAL_ONLY", |
| 1567 | ] |
| 1568 | + self.extra_create_options, |
| 1569 | ) |
| 1570 | # Get the file size |
| 1571 | info = FileAllInformation( |
| 1572 | self.smbsock.query_info( |
| 1573 | FileId=fileId, |
| 1574 | InfoType="SMB2_0_INFO_FILE", |
| 1575 | FileInfoClass="FileAllInformation", |
| 1576 | ) |
| 1577 | ) |
| 1578 | length = info.StandardInformation.EndOfFile |
| 1579 | offset = 0 |
| 1580 | # Read the file |
| 1581 | while length: |
| 1582 | lengthRead = min(self.smbsock.session.MaxReadSize, length) |
| 1583 | fd.write( |
| 1584 | self.smbsock.read_request(fileId, Length=lengthRead, Offset=offset) |
| 1585 | ) |
| 1586 | offset += lengthRead |
| 1587 | length -= lengthRead |
| 1588 | # Close the file |
| 1589 | self.smbsock.close_request(fileId) |
| 1590 | return offset |
| 1591 | |
| 1592 | def _send_file(self, fname, fd): |
| 1593 | """ |
no test coverage detected