allow File::write() to take a Span
This commit is contained in:
parent
382d155e40
commit
26f8fb355e
@ -88,8 +88,7 @@ bool Buffer::write_to_file(const char * filename)
|
|||||||
bytes_written += pd->length;
|
bytes_written += pd->length;
|
||||||
if (pd->eol())
|
if (pd->eol())
|
||||||
{
|
{
|
||||||
if (!file.write(LineEndings::spans[m_line_endings].start,
|
if (!file.write(LineEndings::spans[m_line_endings]))
|
||||||
LineEndings::spans[m_line_endings].length))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,8 +98,7 @@ bool Buffer::write_to_file(const char * filename)
|
|||||||
|
|
||||||
if (m_eol_at_eof && bytes_written > 0u)
|
if (m_eol_at_eof && bytes_written > 0u)
|
||||||
{
|
{
|
||||||
if (!file.write(LineEndings::spans[m_line_endings].start,
|
if (!file.write(LineEndings::spans[m_line_endings]))
|
||||||
LineEndings::spans[m_line_endings].length))
|
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "Span.h"
|
||||||
|
|
||||||
class File
|
class File
|
||||||
{
|
{
|
||||||
@ -14,6 +15,10 @@ public:
|
|||||||
size_t get_size();
|
size_t get_size();
|
||||||
bool read(uint8_t * buf, size_t size);
|
bool read(uint8_t * buf, size_t size);
|
||||||
bool write(const uint8_t * buf, size_t size);
|
bool write(const uint8_t * buf, size_t size);
|
||||||
|
bool write(const Span & span)
|
||||||
|
{
|
||||||
|
return write(span.start, span.length);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int m_fd;
|
int m_fd;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user