Archived
1
0
This repository has been archived on 2023-08-12. You can view files and clone it, but cannot push or open issues or pull requests.
nntpchan/contrib/backends/nntpchan-daemon/libnntpchan/file_handle.cpp
2017-10-17 10:29:56 -04:00

22 lines
377 B
C++

#include <nntpchan/file_handle.hpp>
namespace nntpchan
{
FileHandle_ptr OpenFile(const fs::path &fname, FileMode mode)
{
std::fstream *f = new std::fstream;
if (mode == eRead)
{
f->open(fname, std::ios::in);
}
else if (mode == eWrite)
{
f->open(fname, std::ios::out);
}
if (f->is_open())
return FileHandle_ptr(f);
delete f;
return nullptr;
}
}