libwebm_utils: Add FileDeleter.

Put the FILE clean up functor in a common place to avoid duplication.

Change-Id: I7bcb5b3e4df7aa37bb90920ecb8acccf94eeaa57
This commit is contained in:
Tom Finegan
2015-12-16 17:31:58 -08:00
parent d6db1e1960
commit be35869ce3
2 changed files with 12 additions and 10 deletions

View File

@@ -13,6 +13,16 @@
namespace libwebm {
// fclose functor for wrapping FILE in std::unique_ptr.
struct FILEDeleter {
int operator()(FILE* f) {
if (f != nullptr)
return fclose(f);
return 0;
}
};
typedef std::unique_ptr<FILE, FILEDeleter> FilePtr;
struct Range {
Range(std::size_t off, std::size_t len) : offset(off), length(len) {}
Range() = delete;