summaryrefslogtreecommitdiffstats
path: root/twrp-functions.cpp
diff options
context:
space:
mode:
authorVojtech Bocek <vbocek@gmail.com>2013-07-25 22:53:02 +0200
committerGerrit Code Review <gerrit@198.50.184.117>2013-08-24 14:56:48 +0200
commitfafb0c541bb4b24515c57251a44d87825eec90fb (patch)
tree9cddb55ceef8912c8fafe618c98147ff6df19ef6 /twrp-functions.cpp
parentClean-up in partitions.hpp (diff)
downloadandroid_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar
android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.gz
android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.bz2
android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.lz
android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.xz
android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.tar.zst
android_bootable_recovery-fafb0c541bb4b24515c57251a44d87825eec90fb.zip
Diffstat (limited to '')
-rw-r--r--twrp-functions.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 29c70a52b..1d2d63229 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -424,15 +424,17 @@ 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;
+ ifstream file;
+ file.open(fn.c_str(), ios::in);
+
+ if (file.is_open()) {
+ file >> results;
+ file.close();
+ return 0;
}
- LOGINFO("Cannot find file %s\n", fn.c_str());
- return -1;
+
+ LOGINFO("Cannot find file %s\n", fn.c_str());
+ return -1;
}
int TWFunc::read_file(string fn, vector<string>& results) {
@@ -498,7 +500,7 @@ timespec TWFunc::timespec_diff(timespec& start, timespec& end)
return temp;
}
- int TWFunc::drop_caches(void) {
+int TWFunc::drop_caches(void) {
string file = "/proc/sys/vm/drop_caches";
string value = "3";
if (write_file(file, value) != 0)
@@ -714,7 +716,7 @@ int TWFunc::Get_File_Type(string fn) {
string::size_type i = 0;
int firstbyte = 0, secondbyte = 0;
char header[3];
-
+
ifstream f;
f.open(fn.c_str(), ios::in | ios::binary);
f.get(header, 3);
@@ -722,13 +724,12 @@ int TWFunc::Get_File_Type(string fn) {
firstbyte = header[i] & 0xff;
secondbyte = header[++i] & 0xff;
- if (firstbyte == 0x1f && secondbyte == 0x8b) {
+ if (firstbyte == 0x1f && secondbyte == 0x8b)
return 1; // Compressed
- } else if (firstbyte == 0x4f && secondbyte == 0x41) {
+ else if (firstbyte == 0x4f && secondbyte == 0x41)
return 2; // Encrypted
- } else {
+ else
return 0; // Unknown
- }
return 0;
}