RingRacers/src/media/cfile.cpp
2023-02-24 19:21:00 -08:00

34 lines
787 B
C++

// RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2023 by James Robert Roman
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
#include <cerrno>
#include <cstdio>
#include <cstring>
#include <stdexcept>
#include <fmt/format.h>
#include "cfile.hpp"
using namespace srb2::media;
CFile::CFile(const std::string file_name) : name_(file_name)
{
file_ = std::fopen(name(), "wb");
if (file_ == nullptr)
{
throw std::invalid_argument(fmt::format("{}: {}", name(), std::strerror(errno)));
}
}
CFile::~CFile()
{
std::fclose(file_);
}