Skip to content

Commit d3f77d5

Browse files
committed
Fix ReadAt function
1 parent 0de2422 commit d3f77d5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

bindings/storage/File.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ py::class_<BFile, BNode, BPositionIO>(m, "BFile")
6464
py::bytes pyBytes(buffer.data(),bytesRead);
6565
return py::make_tuple(pyBytes, bytesRead);
6666
},"", py::arg("size"))
67-
.def("ReadAt", &BFile::ReadAt, "", py::arg("location"), py::arg("buffer"), py::arg("size"))
67+
//.def("ReadAt", &BFile::ReadAt, "", py::arg("location"), py::arg("buffer"), py::arg("size"))
68+
.def("ReadAt", [](BFile& self, off_t location, size_t size)->py::tuple{
69+
std::vector<char>buffer(size);
70+
ssize_t bytesRead = self.ReadAt(location, buffer.data(), size);
71+
py::bytes pyBytes(buffer.data(),bytesRead);
72+
return py::make_tuple(pyBytes, bytesRead);
73+
},"", py::arg("location"),py::arg("size"))
6874
//.def("Write", &BFile::Write, "", py::arg("buffer"), py::arg("size"))
6975
.def("Write", [](BFile& self, py::buffer buffer){
7076
py::buffer_info info = buffer.request();

0 commit comments

Comments
 (0)