From: Benny Baumann Date: Mon, 23 Feb 2015 18:41:04 +0000 (+0100) Subject: fix: Refine Error Management and note about further plces that need care X-Git-Url: https://code.wpia.club/?p=cassiopeia.git;a=commitdiff_plain;h=87325777087f80af2065a09977ae6abf39bc50d1 fix: Refine Error Management and note about further plces that need care --- diff --git a/src/util.cpp b/src/util.cpp index 5cf30da..ed7b42e 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -14,6 +14,8 @@ void writeFile( const std::string& name, const std::string& content ) { file.open( name ); file << content; file.close(); + + //! \FIXME: Error checking } std::string readFile( const std::string& name ) { @@ -29,12 +31,20 @@ std::string writeBackFile( const std::string& serial, const std::string& cert, c std::string filename = keydir; if( 0 != mkdir( filename.c_str(), 0755 ) ) { - return ""; + if( EEXIST != errno ) { + return ""; + } + + //! \FIXME: Check this is a directory } filename += "/crt"; if( 0 != mkdir( filename.c_str(), 0755 ) ) { - return ""; + if( EEXIST != errno ) { + return ""; + } + + //! \FIXME: Check this is a directory } std::string first; @@ -46,8 +56,13 @@ std::string writeBackFile( const std::string& serial, const std::string& cert, c filename += "/" + first; if( 0 != mkdir( filename.c_str(), 0755 ) ) { - return ""; + if( EEXIST != errno ) { + return ""; + } + + //! \FIXME: Check this is a directory } + filename += "/" + serial + ".crt"; writeFile( filename, cert );