Guest User

Untitled

a guest
May 25th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.93 KB | None | 0 0
  1.             std::stringstream ss;
  2.  
  3.             std::string str;
  4.  
  5.             std::fstream fs("/var/local/app/stats/app_start_count", std::ios::in | std::ios::out);
  6.  
  7.  
  8.             if(fs >> str)
  9.             {
  10.                 if(ss << str)
  11.                 {
  12.  
  13.                     uint32_t app_start_count;
  14.                     if(ss >> app_start_count)
  15.                     {
  16.  
  17.                         ++app_start_count;
  18.  
  19.                         LOG4CXX_INFO(gLogger, "Application start count: " << app_start_count);
  20.  
  21.  
  22.                         fs.seekp(0);
  23.  
  24.                         if(fs << app_start_count)
  25.                         {
  26.                             LOG4CXX_INFO(gLogger, "write successful");
  27.                         }
  28.                         else
  29.                         {
  30.                             LOG4CXX_INFO(gLogger, "write failed");
  31.                         }
  32.                     }
  33.                 }
  34.             }
Add Comment
Please, Sign In to add comment