depthai-sdk-nix/patches/fw-in-nix-store.patch
2022-11-29 14:54:11 -05:00

31 lines
1.4 KiB
Diff

diff --git a/depthai-core/src/utility/Resources.cpp b/depthai-core/src/utility/Resources.cpp
index bca4dbde..e55436ea 100644
--- a/depthai-core/src/utility/Resources.cpp
+++ b/depthai-core/src/utility/Resources.cpp
@@ -255,9 +255,14 @@ std::function<void()> getLazyTarXzFunction(MTX& mtx, CV& cv, BOOL& ready, PATH c
return [&mtx, &cv, &ready, cmrcPath, &resourceList, &resourceMap] {
using namespace std::chrono;
- // Get binaries from internal sources
- auto fs = cmrc::depthai::get_filesystem();
- auto tarXz = fs.open(cmrcPath);
+ std::ifstream file(cmrcPath, std::ios::binary | std::ios::ate);
+ auto size = file.tellg();
+ file.seekg(0, std::ios::beg);
+ std::vector<char> buffer(size);
+ if (!file.read(buffer.data(), size))
+ {
+ throw std::runtime_error(std::string("Could not open file for reading: \"") + cmrcPath + '"');
+ }
auto t1 = steady_clock::now();
@@ -265,7 +270,7 @@ std::function<void()> getLazyTarXzFunction(MTX& mtx, CV& cv, BOOL& ready, PATH c
struct archive* a = archive_read_new();
archive_read_support_filter_xz(a);
archive_read_support_format_tar(a);
- int r = archive_read_open_memory(a, tarXz.begin(), tarXz.size());
+ int r = archive_read_open_memory(a, buffer.data(), size);
assert(r == ARCHIVE_OK);
auto t2 = steady_clock::now();