summaryrefslogtreecommitdiffstats
path: root/otafault/ota_io.cpp
diff options
context:
space:
mode:
authorTao Bao <tbao@google.com>2016-11-28 20:48:43 +0100
committerTao Bao <tbao@google.com>2016-11-28 21:09:39 +0100
commit358c2ec1dca24d48a503b441d38545ace021ea8e (patch)
tree433b869340d93bf43ed46916abbcf1cf218e1fb6 /otafault/ota_io.cpp
parentAdd ota_close(unique_fd&) and ota_fclose(std::unique_ptr<FILE>&). (diff)
downloadandroid_bootable_recovery-358c2ec1dca24d48a503b441d38545ace021ea8e.tar
android_bootable_recovery-358c2ec1dca24d48a503b441d38545ace021ea8e.tar.gz
android_bootable_recovery-358c2ec1dca24d48a503b441d38545ace021ea8e.tar.bz2
android_bootable_recovery-358c2ec1dca24d48a503b441d38545ace021ea8e.tar.lz
android_bootable_recovery-358c2ec1dca24d48a503b441d38545ace021ea8e.tar.xz
android_bootable_recovery-358c2ec1dca24d48a503b441d38545ace021ea8e.tar.zst
android_bootable_recovery-358c2ec1dca24d48a503b441d38545ace021ea8e.zip
Diffstat (limited to 'otafault/ota_io.cpp')
-rw-r--r--otafault/ota_io.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/otafault/ota_io.cpp b/otafault/ota_io.cpp
index 874cb1d5c..f5b01136f 100644
--- a/otafault/ota_io.cpp
+++ b/otafault/ota_io.cpp
@@ -70,23 +70,31 @@ FILE* ota_fopen(const char* path, const char* mode) {
return fh;
}
-int ota_close(int fd) {
+static int __ota_close(int fd) {
// descriptors can be reused, so make sure not to leave them in the cache
filename_cache.erase(fd);
return close(fd);
}
+void OtaCloser::Close(int fd) {
+ __ota_close(fd);
+}
+
int ota_close(unique_fd& fd) {
- return ota_close(fd.release());
+ return __ota_close(fd.release());
}
-int ota_fclose(FILE* fh) {
- filename_cache.erase((intptr_t)fh);
+static int __ota_fclose(FILE* fh) {
+ filename_cache.erase(reinterpret_cast<intptr_t>(fh));
return fclose(fh);
}
-int ota_fclose(std::unique_ptr<FILE, int (*)(FILE*)>& fh) {
- return ota_fclose(fh.release());
+void OtaFcloser::operator()(FILE* f) {
+ __ota_fclose(f);
+};
+
+int ota_fclose(unique_file& fh) {
+ return __ota_fclose(fh.release());
}
size_t ota_fread(void* ptr, size_t size, size_t nitems, FILE* stream) {