Add File::open(), use inside File::open_for_append().

This commit is contained in:
Jared Boone 2016-02-18 21:33:38 -08:00
parent 6b97490794
commit 083711ceb2
2 changed files with 7 additions and 2 deletions

View File

@ -25,9 +25,13 @@ File::~File() {
close();
}
bool File::open_for_append(const std::string& file_path) {
bool File::open(const std::string& file_path) {
const auto open_result = f_open(&f, file_path.c_str(), FA_WRITE | FA_OPEN_ALWAYS);
if( open_result == FR_OK ) {
return (open_result == FR_OK);
}
bool File::open_for_append(const std::string& file_path) {
if( open(file_path) ) {
const auto seek_result = f_lseek(&f, f_size(&f));
if( seek_result == FR_OK ) {
return true;

View File

@ -31,6 +31,7 @@ class File {
public:
~File();
bool open(const std::string& file_path);
bool open_for_append(const std::string& file_path);
bool close();