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

Function untar

Tactility/Source/app/AppInstall.cpp:52–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52static bool untar(const std::string& tarPath, const std::string& destinationPath) {
53 minitar mp;
54 if (minitar_open(tarPath.c_str(), &mp) != 0) {
55 perror(tarPath.c_str());
56 return 1;
57 }
58 bool success = true;
59 minitar_entry entry;
60
61 do {
62 if (minitar_read_entry(&mp, &entry) == 0) {
63 LOGGER.info("Extracting {}", entry.metadata.path);
64 if (entry.metadata.type == MTAR_DIRECTORY) {
65 if (!strcmp(entry.metadata.name, ".") || !strcmp(entry.metadata.name, "..") || !strcmp(entry.metadata.name, "/")) continue;
66 if (!untarDirectory(&entry, destinationPath)) {
67 LOGGER.error("Failed to create directory {}/{}: {}", destinationPath, entry.metadata.name, strerror(errno));
68 success = false;
69 break;
70 }
71 } else if (entry.metadata.type == MTAR_REGULAR) {
72 if (!untarFile(&mp, &entry, destinationPath)) {
73 LOGGER.error("Failed to extract file {}: {}", entry.metadata.path, strerror(errno));
74 success = false;
75 break;
76 }
77 } else if (entry.metadata.type == MTAR_SYMLINK) {
78 LOGGER.error("SYMLINK not supported");
79 } else if (entry.metadata.type == MTAR_HARDLINK) {
80 LOGGER.error("HARDLINK not supported");
81 } else if (entry.metadata.type == MTAR_FIFO) {
82 LOGGER.error("FIFO not supported");
83 } else if (entry.metadata.type == MTAR_BLKDEV) {
84 LOGGER.error("BLKDEV not supported");
85 } else if (entry.metadata.type == MTAR_CHRDEV) {
86 LOGGER.error("CHRDEV not supported");
87 } else {
88 LOGGER.error("Unknown entry type: {}", static_cast<int>(entry.metadata.type));
89 success = false;
90 break;
91 }
92 } else break;
93 } while (true);
94 minitar_close(&mp);
95 return success;
96}
97
98void cleanupInstallDirectory(const std::string& path) {
99 if (!file::deleteRecursively(path)) {

Callers 1

installFunction · 0.85

Calls 4

untarDirectoryFunction · 0.85
untarFileFunction · 0.85
infoMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected