summaryrefslogtreecommitdiffstats
path: root/base/file_util.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/file_util.h')
-rw-r--r--base/file_util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/base/file_util.h b/base/file_util.h
index 9eb1729..543a86c 100644
--- a/base/file_util.h
+++ b/base/file_util.h
@@ -371,6 +371,20 @@ class ScopedFILEClose {
typedef scoped_ptr_malloc<FILE, ScopedFILEClose> ScopedFILE;
+#if defined(OS_POSIX)
+// A class to handle auto-closing of FDs.
+class ScopedFDClose {
+ public:
+ inline void operator()(int* x) const {
+ if (x) {
+ close(*x);
+ }
+ }
+};
+
+typedef scoped_ptr_malloc<int, ScopedFDClose> ScopedFD;
+#endif // OS_POSIX
+
// A class for enumerating the files in a provided path. The order of the
// results is not guaranteed.
//