|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r65227 - sandbox/gil/boost/gil/extension/io2/detail
From: dsaritz_at_[hidden]
Date: 2010-09-03 17:28:44
Author: psiha
Date: 2010-09-03 17:28:43 EDT (Fri, 03 Sep 2010)
New Revision: 65227
URL: http://svn.boost.org/trac/boost/changeset/65227
Log:
Added the c_file_guard shared RAII class.
Text files modified:
sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
Modified: sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp
==============================================================================
--- sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp (original)
+++ sandbox/gil/boost/gil/extension/io2/detail/libx_shared.hpp 2010-09-03 17:28:43 EDT (Fri, 03 Sep 2010)
@@ -59,6 +59,24 @@
value_type const end_row_;
};
+
+class c_file_guard
+{
+public:
+ c_file_guard( char const * const file_name )
+ :
+ p_file_( /*std*/::fopen( file_name, "rb" ) )
+ {
+ io_error_if( !p_file_, "File open failure" );
+ }
+ ~c_file_guard() { /*std*/::fclose( p_file_ ); }
+
+ FILE & get() const { return *p_file_; }
+
+private:
+ FILE * const p_file_;
+};
+
//------------------------------------------------------------------------------
} // namespace detail
//------------------------------------------------------------------------------
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk