|
|
1.1 ! root 1: /* ! 2: Copyright (c) 2008 TrueCrypt Foundation. All rights reserved. ! 3: ! 4: Governed by the TrueCrypt License 2.4 the full text of which is contained ! 5: in the file License.txt included in TrueCrypt binary and source code ! 6: distribution packages. ! 7: */ ! 8: ! 9: #include <errno.h> ! 10: #include <string.h> ! 11: #include "Platform/SerializerFactory.h" ! 12: #include "Platform/SystemException.h" ! 13: #include "Platform/StringConverter.h" ! 14: ! 15: namespace TrueCrypt ! 16: { ! 17: SystemException::SystemException (const string &message) ! 18: : Exception (message), ErrorCode (errno) ! 19: { ! 20: } ! 21: ! 22: SystemException::SystemException (const string &message, const string &subject) ! 23: : Exception (message, StringConverter::ToWide (subject)), ErrorCode (errno) ! 24: { ! 25: } ! 26: ! 27: SystemException::SystemException (const string &message, const wstring &subject) ! 28: : Exception (message, subject), ErrorCode (errno) ! 29: { ! 30: } ! 31: ! 32: void SystemException::Deserialize (shared_ptr <Stream> stream) ! 33: { ! 34: Exception::Deserialize (stream); ! 35: Serializer sr (stream); ! 36: sr.Deserialize ("ErrorCode", ErrorCode); ! 37: } ! 38: ! 39: bool SystemException::IsError () const ! 40: { ! 41: return ErrorCode != 0; ! 42: } ! 43: ! 44: void SystemException::Serialize (shared_ptr <Stream> stream) const ! 45: { ! 46: Exception::Serialize (stream); ! 47: Serializer sr (stream); ! 48: sr.Serialize ("ErrorCode", ErrorCode); ! 49: } ! 50: ! 51: wstring SystemException::SystemText () const ! 52: { ! 53: return StringConverter::ToWide (strerror (ErrorCode)); ! 54: } ! 55: ! 56: #define TC_EXCEPTION(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) ! 57: #undef TC_EXCEPTION_NODECL ! 58: #define TC_EXCEPTION_NODECL(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) ! 59: ! 60: TC_SERIALIZER_FACTORY_ADD_EXCEPTION_SET (SystemException); ! 61: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.