Home | History | Annotate | Download | only in fuzz
      1 class EncoderFormat {
      2 public:
      3   std::string get() { return std::string(_format.begin(), _format.end()); } const
      4   void set(const std::wstring fileName, const std::wstring extension)
      5   {
      6     if (fileName.find(L"clusterfuzz-testcase-") == -1)
      7     {
      8       if (extension.length() > 1)
      9         _format = extension.substr(1, extension.size() - 1);
     10       return;
     11     }
     12 
     13     std::wstring format=fileName;
     14 
     15     size_t index = format.find(L"_", 0);
     16     if (index == std::wstring::npos)
     17       return;
     18 
     19     format=format.substr(index + 1);
     20     index = format.find(L"_", 0);
     21     if (index != std::wstring::npos)
     22       _format=format.substr(0, index);
     23     else if (extension.length() > 1)
     24       _format=extension.substr(1, extension.size() - 1);
     25   }
     26 private:
     27   std::wstring _format = L".notset";
     28 };