summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorbigbiff bigbiff <bigbiff@teamw.in>2013-02-28 03:11:26 +0100
committerbigbiff bigbiff <bigbiff@teamw.in>2013-03-07 14:07:34 +0100
commitcdcfee48b9720d589a4e2cd43725e8229ca336f9 (patch)
treeb4665ae32649baa623cd8d49d15d190c56ab2370 /twrp-functions.cpp
parentMerge "Fix capturing exit status to properly display libtar results" into twrp2.4 (diff)
downloadandroid_bootable_recovery-cdcfee48b9720d589a4e2cd43725e8229ca336f9.tar
android_bootable_recovery-cdcfee48b9720d589a4e2cd43725e8229ca336f9.tar.gz
android_bootable_recovery-cdcfee48b9720d589a4e2cd43725e8229ca336f9.tar.bz2
android_bootable_recovery-cdcfee48b9720d589a4e2cd43725e8229ca336f9.tar.lz
android_bootable_recovery-cdcfee48b9720d589a4e2cd43725e8229ca336f9.tar.xz
android_bootable_recovery-cdcfee48b9720d589a4e2cd43725e8229ca336f9.tar.zst
android_bootable_recovery-cdcfee48b9720d589a4e2cd43725e8229ca336f9.zip
Diffstat (limited to '')
-rw-r--r--twrp-functions.cpp58
1 files changed, 15 insertions, 43 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index a90be5a6d..76ee93a1e 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -49,48 +49,6 @@ int TWFunc::Exec_Cmd(string cmd, string &result) {
return ret;
}
-/* Checks md5 for a path
- Return values:
- -1 : MD5 does not exist
- 0 : Failed
- 1 : Success */
-int TWFunc::Check_MD5(string File) {
- int ret;
- string Command, DirPath, MD5_File, Sline, Filename, MD5_File_Filename, OK;
- char line[255];
- size_t pos;
- string result;
-
- MD5_File = File + ".md5";
- if (Path_Exists(MD5_File)) {
- DirPath = Get_Path(File);
- MD5_File = Get_Filename(MD5_File);
- Command = "cd '" + DirPath + "' && /sbin/busybox md5sum -c '" + MD5_File + "'";
- Exec_Cmd(Command, result);
- pos = result.find(":");
- if (pos != string::npos) {
- Filename = Get_Filename(File);
- MD5_File_Filename = result.substr(0, pos);
- OK = result.substr(pos + 2, result.size() - pos - 2);
- if (Filename == MD5_File_Filename && (OK == "OK" || OK == "OK\n")) {
- //MD5 is good, return 1
- ret = 1;
- } else {
- // MD5 is bad, return 0
- ret = 0;
- }
- } else {
- // MD5 is bad, return 0
- ret = 0;
- }
- } else {
- //No md5 file, return -1
- ret = -1;
- }
-
- return ret;
-}
-
// Returns "file.name" from a full /path/to/file.name
string TWFunc::Get_Filename(string Path) {
size_t pos = Path.find_last_of("/");
@@ -482,10 +440,24 @@ unsigned int TWFunc::Get_D_Type_From_Stat(string Path) {
}
int TWFunc::read_file(string fn, string& results) {
+ ifstream file;
+ file.open(fn.c_str(), ios::in);
+ if (file.is_open()) {
+ file >> results;
+ file.close();
+ return 0;
+ }
+ LOGI("Cannot find file %s\n", fn.c_str());
+ return -1;
+}
+
+int TWFunc::read_file(string fn, vector<string>& results) {
ifstream file;
+ string line;
file.open(fn.c_str(), ios::in);
if (file.is_open()) {
- file >> results;
+ while (getline(file, line))
+ results.push_back(line);
file.close();
return 0;
}