#include "file_util.h"
#include <stdlib.h>
#if defined(OPENSSL_WINDOWS)
OPENSSL_MSVC_PRAGMA(warning(push, 3))
#include <windows.h>
OPENSSL_MSVC_PRAGMA(warning(pop))
#else
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#endif
#include <openssl/rand.h>
#include "test_util.h"
BSSL_NAMESPACE_BEGIN
#if defined(OPENSSL_WINDOWS)
static void PrintLastError(const char *s) {
DWORD error = GetLastError();
char *buffer;
DWORD len = FormatMessageA(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, error, 0,
reinterpret_cast<char *>(&buffer), 0, nullptr);
std::string msg = "unknown error";
if (len > 0) {
msg.assign(buffer, len);
while (!msg.empty() && (msg.back() == '\r' || msg.back() == '\n')) {
msg.resize(msg.size() - 1);
}
}
LocalFree(buffer);
fprintf(stderr, "%s: %s (0x%lx)\n", s, msg.c_str(), error);
}
#endif
static std::string GetTempDir() { … }
bool SkipTempFileTests() { … }
TemporaryFile::~TemporaryFile() { … }
bool TemporaryFile::Init(bssl::Span<const uint8_t> content) { … }
ScopedFILE TemporaryFile::Open(const char *mode) const { … }
ScopedFD TemporaryFile::OpenFD(int flags) const { … }
TemporaryDirectory::~TemporaryDirectory() { … }
bool TemporaryDirectory::Init() { … }
bool TemporaryDirectory::AddFile(const std::string &filename,
bssl::Span<const uint8_t> content) { … }
BSSL_NAMESPACE_END