1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-12-20 01:41:40 +03:00

fix create_buffer_from_file when file does not exists

This commit is contained in:
Maxime Coste 2012-08-17 18:52:04 +02:00
parent 8a6e8cd898
commit 7cc5ff7c73

View File

@ -75,11 +75,6 @@ String read_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);
if (fd == -1)
{
@ -89,6 +84,12 @@ Buffer* create_buffer_from_file(const String& filename)
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;
char buf[256];
bool crlf = false;