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);
78 std::string
DirName(
const std::string &FileName) {
79 char *Tmp =
new char[FileName.size() + 1];
80 memcpy(Tmp, FileName.c_str(), FileName.size() + 1);
81 std::string Res = dirname(Tmp);
87 if (
auto Env = getenv(
"TMPDIR"))
94 #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)
static GCRegistry::Add< StatepointGC > D("statepoint-example","an example strategy for statepoint")
long GetEpoch(const std::string &Path)
static GCRegistry::Add< CoreCLRGC > E("coreclr","CoreCLR-compatible GC")
void Printf(const char *Fmt,...)
FILE * OpenFile(int Fd, const char *Mode)
std::string DirPlusFile(const std::string &DirPath, const std::string &FileName)
void RemoveFile(const std::string &Path)
std::string DirName(const std::string &FileName)