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

23 lines
401 B
C++
Raw Normal View History

#include "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;
}
}