X-Git-Url: http://code.wpia.club/?a=blobdiff_plain;f=src%2Futil.cpp;h=ed7b42e61ff87a407c981ff791cd92d05459136a;hb=87325777087f80af2065a09977ae6abf39bc50d1;hp=5cf30da1d2dac01576e6ce5dce6dbaa4f845add4;hpb=91814cbc6f74173f40278062f8de1859c9b2e7c4;p=cassiopeia.git 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 );