Files
composable_kernel/host/online_compilation/include/write_file.hpp
Chao Liu 1264925422 reorganize files to prepare for MIOpen integration (#51)
* change olc cmake

* adding online compile to fwd-v4r5r2

* update scripts

* remane fwd-v4r5r2 to fwd-v6r1

* clean up
2021-07-18 00:43:05 -05:00

31 lines
952 B
C++

#ifndef GUARD_OLC_WRITE_FILE_HPP
#define GUARD_OLC_WRITE_FILE_HPP
#include <boost/filesystem.hpp>
#include <manage_ptr.hpp>
#include <fstream>
namespace olCompile {
using FilePtr = OLC_MANAGE_PTR(FILE*, std::fclose);
inline void WriteFile(const std::string& content, const boost::filesystem::path& name)
{
// std::cerr << "Write file: " << name << std::endl;
FilePtr f{std::fopen(name.string().c_str(), "w")};
if(std::fwrite(content.c_str(), 1, content.size(), f.get()) != content.size())
throw std::runtime_error("Failed to write to file");
}
inline void WriteFile(const std::vector<char>& content, const boost::filesystem::path& name)
{
// std::cerr << "Write file: " << name << std::endl;
FilePtr f{std::fopen(name.string().c_str(), "w")};
if(std::fwrite(&content[0], 1, content.size(), f.get()) != content.size())
throw std::runtime_error("Failed to write to file");
}
} // namespace olCompile
#endif