| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- #ifndef BASE_FILES_SCOPED_FILE_H_
- #define BASE_FILES_SCOPED_FILE_H_
- #include <stdio.h>
- #include <memory>
- #include "base/base_export.h"
- #include "base/scoped_generic.h"
- #include "build/build_config.h"
- namespace base {
- namespace internal {
- #if defined(OS_ANDROID)
- struct BASE_EXPORT ScopedFDCloseTraits : public ScopedGenericOwnershipTracking {
- static int InvalidValue() { return -1; }
- static void Free(int);
- static void Acquire(const ScopedGeneric<int, ScopedFDCloseTraits>&, int);
- static void Release(const ScopedGeneric<int, ScopedFDCloseTraits>&, int);
- };
- #elif defined(OS_POSIX) || defined(OS_FUCHSIA)
- struct BASE_EXPORT ScopedFDCloseTraits {
- static int InvalidValue() {
- return -1;
- }
- static void Free(int fd);
- };
- #endif
- struct ScopedFILECloser {
- inline void operator()(FILE* x) const {
- if (x)
- fclose(x);
- }
- };
- }
- #if defined(OS_POSIX) || defined(OS_FUCHSIA)
- typedef ScopedGeneric<int, internal::ScopedFDCloseTraits> ScopedFD;
- #endif
- typedef std::unique_ptr<FILE, internal::ScopedFILECloser> ScopedFILE;
- }
- #endif
|