OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_EDK_UTIL_SCOPED_FILE_H_ |
| 6 #define MOJO_EDK_UTIL_SCOPED_FILE_H_ |
| 7 |
| 8 #include <stdio.h> |
| 9 |
| 10 #include "base/memory/scoped_ptr.h" |
| 11 |
| 12 namespace mojo { |
| 13 namespace util { |
| 14 namespace internal { |
| 15 |
| 16 // Functor for |ScopedFILE| (below). |
| 17 struct ScopedFILECloser { |
| 18 inline void operator()(FILE* x) const { |
| 19 if (x) |
| 20 fclose(x); |
| 21 } |
| 22 }; |
| 23 |
| 24 } // namespace internal |
| 25 |
| 26 // Automatically closes |FILE*|s. |
| 27 using ScopedFILE = scoped_ptr<FILE, internal::ScopedFILECloser>; |
| 28 |
| 29 } // namespace util |
| 30 } // namespace mojo |
| 31 |
| 32 #endif // MOJO_EDK_UTIL_SCOPED_FILE_H_ |
OLD | NEW |