MCPcopy Create free account
hub / github.com/TactilityProject/Tactility / untarFile

Function untarFile

Tactility/Source/app/AppInstall.cpp:25–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23static const auto LOGGER = Logger("App");
24
25static bool untarFile(minitar* mp, const minitar_entry* entry, const std::string& destinationPath) {
26 const auto absolute_path = destinationPath + "/" + entry->metadata.path;
27 if (!file::findOrCreateDirectory(destinationPath, 0777)) {
28 LOGGER.error("Can't find or create directory {}", destinationPath.c_str());
29 return false;
30 }
31
32 // minitar_read_contents(&mp, &entry, file_buffer, entry.metadata.size);
33 if (!minitar_read_contents_to_file(mp, entry, absolute_path.c_str())) {
34 LOGGER.error("Failed to write data to {}", absolute_path.c_str());
35 return false;
36 }
37
38 // Note: fchmod() doesn't exist on ESP-IDF and chmod() does nothing on that platform
39 if (chmod(absolute_path.c_str(), entry->metadata.mode) < 0) {
40 return false;
41 }
42
43 return true;
44}
45
46static bool untarDirectory(const minitar_entry* entry, const std::string& destinationPath) {
47 auto absolute_path = destinationPath + "/" + entry->metadata.path;

Callers 1

untarFunction · 0.85

Calls 2

findOrCreateDirectoryFunction · 0.85
errorMethod · 0.80

Tested by

no test coverage detected