ADB Backup: Fix gzip backup and restore
Change-Id: I92821c7053089d130a5ab73fa36aec486da77bf1
diff --git a/adbbu/libtwadbbu.cpp b/adbbu/libtwadbbu.cpp
index a13ecb2..0c7f355 100644
--- a/adbbu/libtwadbbu.cpp
+++ b/adbbu/libtwadbbu.cpp
@@ -33,6 +33,7 @@
#include "twadbstream.h"
#include "libtwadbbu.hpp"
+#include "twrpback.hpp"
bool twadbbu::Check_ADB_Backup_File(std::string fname) {
struct AdbBackupStreamHeader adbbuhdr;
@@ -290,3 +291,16 @@
close(adb_control_bu_fd);
return true;
}
+
+bool twadbbu::Write_TWDATA(FILE* adbd_fp) {
+ struct AdbBackupControlType data_block;
+ memset(&data_block, 0, sizeof(data_block));
+ strncpy(data_block.start_of_header, TWRP, sizeof(data_block.start_of_header));
+ strncpy(data_block.type, TWDATA, sizeof(data_block.type));
+ data_block.crc = crc32(0L, Z_NULL, 0);
+ data_block.crc = crc32(data_block.crc, (const unsigned char*) &data_block, sizeof(data_block));
+ if (fwrite(&data_block, 1, sizeof(data_block), adbd_fp) != sizeof(data_block)) {
+ return false;
+ }
+ return true;
+}