mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-20 18:11:36 +03:00
fix create_buffer_from_file when file does not exists
This commit is contained in:
parent
8a6e8cd898
commit
7cc5ff7c73
11
src/file.cc
11
src/file.cc
@ -75,11 +75,6 @@ String read_file(const String& filename)
|
|||||||
|
|
||||||
Buffer* create_buffer_from_file(const String& filename)
|
Buffer* create_buffer_from_file(const String& filename)
|
||||||
{
|
{
|
||||||
if (Buffer* buffer = BufferManager::instance().get_buffer(filename))
|
|
||||||
delete buffer;
|
|
||||||
|
|
||||||
Buffer* buffer = new Buffer(filename, Buffer::Type::File, "");
|
|
||||||
|
|
||||||
int fd = open(filename.c_str(), O_RDONLY);
|
int fd = open(filename.c_str(), O_RDONLY);
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
{
|
{
|
||||||
@ -89,6 +84,12 @@ Buffer* create_buffer_from_file(const String& filename)
|
|||||||
throw file_access_error(filename, strerror(errno));
|
throw file_access_error(filename, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Buffer* buffer = BufferManager::instance().get_buffer(filename))
|
||||||
|
delete buffer;
|
||||||
|
|
||||||
|
Buffer* buffer = new Buffer(filename, Buffer::Type::File, "");
|
||||||
|
|
||||||
|
|
||||||
String content;
|
String content;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
bool crlf = false;
|
bool crlf = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user