#include "./fuzztest/internal/io.h"
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <optional>
#include <sstream>
#include <string>
#include <string_view>
#include <tuple>
#include <utility>
#include <vector>
#include "absl/hash/hash.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "./fuzztest/internal/logging.h"
#if defined(__APPLE__)
#if (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && \
__MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_15) || \
(defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && \
__IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_13_0)
#define FUZZTEST_STUB_FILESYSTEM
#endif
#endif
namespace fuzztest::internal {
#if defined(FUZZTEST_STUB_FILESYSTEM)
bool WriteFile(absl::string_view path, absl::string_view contents) {
FUZZTEST_INTERNAL_CHECK(false, "Filesystem API not supported in iOS/MacOS");
}
std::optional<std::string> ReadFile(absl::string_view path) {
FUZZTEST_INTERNAL_CHECK(false, "Filesystem API not supported in iOS/MacOS");
}
bool IsDirectory(absl::string_view path) {
FUZZTEST_INTERNAL_CHECK(false, "Filesystem API not supported in iOS/MacOS");
}
bool CreateDirectory(absl::string_view path) {
FUZZTEST_INTERNAL_CHECK(false, "Filesystem API not supported in iOS/MacOS");
}
std::vector<std::string> ListDirectory(absl::string_view path) {
FUZZTEST_INTERNAL_CHECK(false, "Filesystem API not supported in iOS/MacOS");
}
std::vector<std::string> ListDirectoryRecursively(absl::string_view path) {
FUZZTEST_INTERNAL_CHECK(false, "Filesystem API not supported in iOS/MacOS");
}
#else
bool WriteFile(absl::string_view path, absl::string_view contents) { … }
std::optional<std::string> ReadFile(absl::string_view path) { … }
bool IsDirectory(absl::string_view path) { … }
bool CreateDirectory(absl::string_view path) { … }
std::vector<std::string> ListDirectory(absl::string_view path) { … }
std::vector<std::string> ListDirectoryRecursively(absl::string_view path) { … }
#endif
std::string WriteDataToDir(absl::string_view data, absl::string_view outdir) { … }
std::vector<FilePathAndData> ReadFileOrDirectory(
absl::string_view file_or_dir) { … }
absl::string_view Basename(absl::string_view filename) { … }
std::vector<std::tuple<std::string>> ReadFilesFromDirectory(
absl::string_view dir) { … }
}