00001 #ifndef CLASSLIB_SAVE_ERRNO_H
00002 # define CLASSLIB_SAVE_ERRNO_H
00003
00004
00005
00006 # include "classlib/sysapi/system.h"
00007 # ifdef _WIN32
00008 # include <windows.h>
00009 # endif
00010 # include <cerrno>
00011
00012 namespace lat {
00013
00014
00015
00016
00017
00018
00019
00022 class SaveErrno
00023 {
00024 public:
00025 SaveErrno (void);
00026 ~SaveErrno (void);
00027
00028
00029
00030 private:
00031 int m_errno;
00032 int m_winerr;
00033 };
00034
00035
00036
00037
00039 inline
00040 SaveErrno::SaveErrno (void)
00041 {
00042 m_errno = errno;
00043 # ifdef _WIN32
00044 m_winerr = GetLastError ();
00045 # endif
00046 }
00047
00049 inline
00050 SaveErrno::~SaveErrno (void)
00051 {
00052 errno = m_errno;
00053 # ifdef _WIN32
00054 SetLastError (m_winerr);
00055 # endif
00056 }
00057
00058 }
00059 #endif // CLASSLIB_SAVE_ERRNO_H