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

22 lines
377 B
C++
Raw Normal View History

2017-10-11 18:48:27 +05:00
#include <nntpchan/file_handle.hpp>
namespace nntpchan
{
2017-10-17 19:29:56 +05:00
FileHandle_ptr OpenFile(const fs::path &fname, FileMode mode)
{
std::fstream *f = new std::fstream;
if (mode == eRead)
{
2017-10-17 19:29:56 +05:00
f->open(fname, std::ios::in);
}
2017-10-17 19:29:56 +05:00
else if (mode == eWrite)
{
f->open(fname, std::ios::out);
}
if (f->is_open())
return FileHandle_ptr(f);
delete f;
return nullptr;
}
}