mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-25 07:19:28 -05:00
Add File seek support.
This commit is contained in:
parent
c5cae1034e
commit
80f94cbc29
@ -63,6 +63,17 @@ bool File::write(const void* const data, const size_t bytes_to_write) {
|
||||
return (result == FR_OK) && (bytes_written == bytes_to_write);
|
||||
}
|
||||
|
||||
uint64_t File::seek(const uint64_t new_position) {
|
||||
const auto old_position = f_tell(&f);
|
||||
if( f_lseek(&f, new_position) != FR_OK ) {
|
||||
f_close(&f);
|
||||
}
|
||||
if( f_tell(&f) != new_position ) {
|
||||
f_close(&f);
|
||||
}
|
||||
return old_position;
|
||||
}
|
||||
|
||||
bool File::puts(const std::string& string) {
|
||||
const auto result = f_puts(string.c_str(), &f);
|
||||
return (result >= 0);
|
||||
|
@ -51,6 +51,8 @@ public:
|
||||
bool read(void* const data, const size_t bytes_to_read);
|
||||
bool write(const void* const data, const size_t bytes_to_write);
|
||||
|
||||
uint64_t seek(const uint64_t new_position);
|
||||
|
||||
template<size_t N>
|
||||
bool write(const std::array<uint8_t, N>& data) {
|
||||
return write(data.data(), N);
|
||||
|
Loading…
Reference in New Issue
Block a user