"Fossies" - the Fresh Open Source Software Archive

Member "src/Platform/Unix/SystemException.cpp" (10 Oct 2018, 1912 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "SystemException.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #include <errno.h>
   14 #include <string.h>
   15 #include "Platform/SerializerFactory.h"
   16 #include "Platform/SystemException.h"
   17 #include "Platform/StringConverter.h"
   18 
   19 namespace VeraCrypt
   20 {
   21     SystemException::SystemException ()
   22         : ErrorCode (errno)
   23     {
   24     }
   25 
   26     SystemException::SystemException (const string &message)
   27         : Exception (message), ErrorCode (errno)
   28     {
   29     }
   30 
   31     SystemException::SystemException (const string &message, const string &subject)
   32         : Exception (message, StringConverter::ToWide (subject)), ErrorCode (errno)
   33     {
   34     }
   35 
   36     SystemException::SystemException (const string &message, const wstring &subject)
   37         : Exception (message, subject), ErrorCode (errno)
   38     {
   39     }
   40 
   41     void SystemException::Deserialize (shared_ptr <Stream> stream)
   42     {
   43         Exception::Deserialize (stream);
   44         Serializer sr (stream);
   45         sr.Deserialize ("ErrorCode", ErrorCode);
   46     }
   47 
   48     bool SystemException::IsError () const
   49     {
   50         return ErrorCode != 0;
   51     }
   52 
   53     void SystemException::Serialize (shared_ptr <Stream> stream) const
   54     {
   55         Exception::Serialize (stream);
   56         Serializer sr (stream);
   57         sr.Serialize ("ErrorCode", ErrorCode);
   58     }
   59 
   60     wstring SystemException::SystemText () const
   61     {
   62         return StringConverter::ToWide (strerror ((int) ErrorCode));
   63     }
   64 
   65 #define TC_EXCEPTION(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE)
   66 #undef TC_EXCEPTION_NODECL
   67 #define TC_EXCEPTION_NODECL(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE)
   68 
   69     TC_SERIALIZER_FACTORY_ADD_EXCEPTION_SET (SystemException);
   70 }