1//===- FuzzerIO.h - Internal header for IO utils ----------------*- C++ -* ===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// IO interface. 10//===----------------------------------------------------------------------===// 11 12#ifndef LLVM_FUZZER_IO_H 13#define LLVM_FUZZER_IO_H 14 15#include "FuzzerDefs.h" 16 17namespace fuzzer { 18 19long GetEpoch(const std::string &Path); 20 21Unit FileToVector(const std::string &Path, size_t MaxSize = 0, 22 bool ExitOnError = true); 23 24std::string FileToString(const std::string &Path); 25 26void CopyFileToErr(const std::string &Path); 27 28void WriteToFile(const Unit &U, const std::string &Path); 29 30void ReadDirToVectorOfUnits(const char *Path, std::vector<Unit> *V, 31 long *Epoch, size_t MaxSize, bool ExitOnError); 32 33// Returns "Dir/FileName" or equivalent for the current OS. 34std::string DirPlusFile(const std::string &DirPath, 35 const std::string &FileName); 36 37// Returns the name of the dir, similar to the 'dirname' utility. 38std::string DirName(const std::string &FileName); 39 40void DupAndCloseStderr(); 41 42void CloseStdout(); 43 44void Printf(const char *Fmt, ...); 45 46// Platform specific functions: 47bool IsFile(const std::string &Path); 48 49void ListFilesInDirRecursive(const std::string &Dir, long *Epoch, 50 std::vector<std::string> *V, bool TopDir); 51 52char GetSeparator(); 53 54FILE* OpenFile(int Fd, const char *Mode); 55 56int CloseFile(int Fd); 57 58int DuplicateFile(int Fd); 59 60void RemoveFile(const std::string &Path); 61 62} // namespace fuzzer 63 64#endif // LLVM_FUZZER_IO_H 65