23 #include <sys/types.h>
28 bool IsFile(
const std::string &Path) {
30 if (stat(Path.c_str(), &St))
32 return S_ISREG(St.st_mode);
36 std::vector<std::string> *V,
bool TopDir) {
39 if (
E && *Epoch >=
E)
return;
41 DIR *
D = opendir(Dir.c_str());
43 Printf(
"No such directory: %s; exiting\n", Dir.c_str());
46 while (
auto E = readdir(D)) {
48 if (
E->d_type == DT_REG ||
E->d_type == DT_LNK)
50 else if (
E->d_type == DT_DIR && *
E->d_name !=
'.')
63 return fdopen(Fd, Mode);
79 FILE* Temp = fopen(
"/dev/null",
"w");
82 dup2(fileno(Temp), Fd);
90 std::string
DirName(
const std::string &FileName) {
91 char *Tmp =
new char[FileName.size() + 1];
92 memcpy(Tmp, FileName.c_str(), FileName.size() + 1);
93 std::string Res = dirname(Tmp);
99 if (
auto Env = getenv(
"TMPDIR"))
105 if (FileName.find(
"compiler-rt/lib/") != std::string::npos)
107 if (FileName.find(
"/usr/lib/") != std::string::npos)
109 if (FileName.find(
"/usr/include/") != std::string::npos)
111 if (FileName ==
"<null>")
118 write(2, Str, strlen(Str));
123 #endif // LIBFUZZER_POSIX
int DuplicateFile(int Fd)
void ListFilesInDirRecursive(const std::string &Dir, long *Epoch, std::vector< std::string > *V, bool TopDir)
bool IsFile(const std::string &Path)
long GetEpoch(const std::string &Path)
FILE * OpenFile(int Fd, const char *Mode)
std::string DirPlusFile(const std::string &DirPath, const std::string &FileName)
intptr_t GetHandleFromFd(int fd)
static void write(bool isBE, void *P, T V)
void RemoveFile(const std::string &Path)
void DiscardOutput(int Fd)
std::string DirName(const std::string &FileName)
Printf(" # Score: %d, Used: %d\n", Scores[i], Usages[i])
bool IsInterestingCoverageFile(const std::string &FileName)
void RawPrint(const char *Str)