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-11 09:48:27 -04:00

23 lines
410 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;
}
}