| 639 | } |
| 640 | |
| 641 | std::string Fuzzer::WriteToOutputCorpus(const Unit &U) { |
| 642 | if (Options.OnlyASCII) |
| 643 | assert(IsASCII(U)); |
| 644 | if (Options.OutputCorpus.empty()) |
| 645 | return ""; |
| 646 | std::time_t current_time = std::time(nullptr); |
| 647 | // Convert the timestamp to a string |
| 648 | std::string timestamp_str = std::to_string(current_time); |
| 649 | std::stringstream ss; |
| 650 | ss << std::setw(10) << std::setfill('0') << TotalNumberOfRuns; |
| 651 | std::string Prefix = ss.str(); |
| 652 | std::string Filename = Prefix + '-' + Hash(U) + '-' + timestamp_str; |
| 653 | std::string Path = DirPlusFile(Options.OutputCorpus, Filename); |
| 654 | WriteToFile(U, Path); |
| 655 | if (Options.Verbosity >= 2) |
| 656 | Printf("Written %zd bytes to %s\n", U.size(), Path.c_str()); |
| 657 | return Path; |
| 658 | } |
| 659 | |
| 660 | void Fuzzer::WriteUnitToFileWithPrefix(const Unit &U, const char *Prefix) { |
| 661 | if (!Options.SaveArtifacts) |
no test coverage detected