summaryrefslogtreecommitdiff
path: root/src/file/mail.cpp
diff options
context:
space:
mode:
authoreportnov <eportnov@ibs.ru>2022-09-13 17:30:47 +0300
committereportnov <eportnov@ibs.ru>2022-09-14 09:33:30 +0300
commit942b22b2ef5ba188ea077dd545c5f240a043cf6f (patch)
tree0c7b4585ba47af057db150f6226ffcdeca66c7ba /src/file/mail.cpp
parentbab12f829beb53feb6f48db7a0ef33574740989c (diff)
downloadobmc-sila-smtp-feature/add_new_interfaces.tar.xz
add new interfacesfeature/add_new_interfaces
Diffstat (limited to 'src/file/mail.cpp')
-rw-r--r--src/file/mail.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/file/mail.cpp b/src/file/mail.cpp
index 4da36c5..1516880 100644
--- a/src/file/mail.cpp
+++ b/src/file/mail.cpp
@@ -7,12 +7,11 @@ namespace smtp::file
Mail::Mail( std::string const& path_file )
: mPathFile( path_file )
{
-
}
manage::MailsSet Mail::Read() const
{
- std::ifstream mail_file{ mPathFile };
+ std::ifstream mail_file{ mPathFile, std::fstream::in };
if ( !mail_file.is_open() )
{
//TODO new file
@@ -29,13 +28,14 @@ namespace smtp::file
result.push_back( *parsed_data );
}
}
+ mail_file.close();
return result;
}
bool Mail::Write( manage::MailsSet const& data ) const
{
- std::ofstream settings_file{ mPathFile };
- if ( !settings_file.is_open() )
+ std::ofstream mail_file{ mPathFile, std::fstream::out | std::fstream::trunc };
+ if ( !mail_file.is_open() )
{
//TODO new file
// std::cerr << "Failed to open pcie_devices database \n";
@@ -43,8 +43,9 @@ namespace smtp::file
}
for( const auto& pair : data )
{
- settings_file << pair << "\n";
+ mail_file << pair << "\n";
}
+ mail_file.close();
return true;
}