| 23 | static const auto LOGGER = Logger("App"); |
| 24 | |
| 25 | static 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 | |
| 46 | static bool untarDirectory(const minitar_entry* entry, const std::string& destinationPath) { |
| 47 | auto absolute_path = destinationPath + "/" + entry->metadata.path; |
no test coverage detected