| Index: base/files/scoped_file.h
|
| diff --git a/base/files/scoped_file.h b/base/files/scoped_file.h
|
| index f5d7ecde7bf7b3cf18c927e301643351770fa12b..106f6ad94bf7f3b0e01799a61cb8dfcab914dd95 100644
|
| --- a/base/files/scoped_file.h
|
| +++ b/base/files/scoped_file.h
|
| @@ -9,6 +9,7 @@
|
|
|
| #include "base/base_export.h"
|
| #include "base/logging.h"
|
| +#include "base/memory/scoped_ptr.h"
|
| #include "base/scoped_generic.h"
|
| #include "build/build_config.h"
|
|
|
| @@ -25,8 +26,18 @@ struct BASE_EXPORT ScopedFDCloseTraits {
|
| };
|
| #endif
|
|
|
| +// Functor for |ScopedFILE| (below).
|
| +struct ScopedFILECloser {
|
| + inline void operator()(FILE* x) const {
|
| + if (x)
|
| + fclose(x);
|
| + }
|
| +};
|
| +
|
| } // namespace internal
|
|
|
| +// -----------------------------------------------------------------------------
|
| +
|
| #if defined(OS_POSIX)
|
| // A low-level Posix file descriptor closer class. Use this when writing
|
| // platform-specific code, especially that does non-file-like things with the
|
| @@ -42,6 +53,9 @@ struct BASE_EXPORT ScopedFDCloseTraits {
|
| typedef ScopedGeneric<int, internal::ScopedFDCloseTraits> ScopedFD;
|
| #endif
|
|
|
| +// Automatically closes |FILE*|s.
|
| +typedef scoped_ptr<FILE, internal::ScopedFILECloser> ScopedFILE;
|
| +
|
| } // namespace base
|
|
|
| #endif // BASE_FILES_SCOPED_FILE_H_
|
|
|