MCPcopy Create free account
hub / github.com/LibreSprite/LibreSprite / load

Method load

src/app/script/api/storage_script.cpp:83–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81 }
82
83 bool load(const std::string& key, const std::string& domain) {
84 try {
85 auto path = this->path(key, domain);
86 base::FileHandle handle(base::open_file_with_exception(path, "rb"));
87 fseek(handle.get(), 0, SEEK_END);
88 auto size = ftell(handle.get());
89 fseek(handle.get(), 0, SEEK_SET);
90 std::vector<unsigned char> data;
91 data.resize(size);
92 fread(data.data(), size, 1, handle.get());
93 set(std::string{data.begin(), data.end()}, key, domain);
94 } catch(...) {
95 return false;
96 }
97 return true;
98 }
99
100 std::string save(const std::string& key, const std::string& domain) {
101 auto domainIt = storage.find(domain.empty() ? app::AppScripting::getFileName() : domain);

Callers

nothing calls this directly

Calls 7

pathMethod · 0.95
open_file_with_exceptionFunction · 0.85
getMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected