X-Git-Url: https://code.wpia.club/?a=blobdiff_plain;f=src%2Futil.cpp;h=a052843561302edcf1869df1250bcf11dca04a80;hb=d19fbcd86a265cb99dd8597430e8159e9403c743;hp=c16ba1c6c8d541164fc5ff7fd540aadb74d1e7fa;hpb=d450e7f4282772a0d9ce478bdf8d8a9e1cfcd813;p=cassiopeia.git diff --git a/src/util.cpp b/src/util.cpp index c16ba1c..a052843 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -182,20 +182,24 @@ std::pair parseYearInterval( std::time_t t, const std::string& dat } } -std::shared_ptr openLogfile( const std::string name) { +std::shared_ptr openLogfile( const std::string name ) { struct stat buffer; std::string tname = name; int ctr = 2; - while(stat (tname.c_str(), &buffer) == 0) { - tname = name + "_" + std::to_string(ctr++); + + while( stat( tname.c_str(), &buffer ) == 0 ) { + tname = name + "_" + std::to_string( ctr++ ); } - auto res = std::shared_ptr(new std::ofstream( tname ), - [](std::ofstream *p){ + + auto res = std::shared_ptr( new std::ofstream( tname ), + []( std::ofstream * p ) { p->close(); delete p; - }); - if(! res->good() ){ - throw std::string("Failed to open file for logging: ") + name; + } ); + + if( ! res->good() ) { + throw std::string( "Failed to open file for logging: " ) + name; } + return res; }