Assume filename passed to write_buffer_to_file is already parsed

This commit is contained in:
Maxime Coste 2017-04-20 09:37:04 +01:00
parent 5103b15b84
commit 30e6387071
3 changed files with 4 additions and 5 deletions

View File

@ -280,8 +280,7 @@ void write_buffer_to_fd(Buffer& buffer, int fd)
void write_buffer_to_file(Buffer& buffer, StringView filename) void write_buffer_to_file(Buffer& buffer, StringView filename)
{ {
int fd = open(parse_filename(filename).c_str(), int fd = open(filename.zstr(), O_CREAT | O_WRONLY | O_TRUNC, 0644);
O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd == -1) if (fd == -1)
throw file_access_error(filename, strerror(errno)); throw file_access_error(filename, strerror(errno));

View File

@ -692,9 +692,9 @@ int run_filter(StringView keystr, StringView commands, ConstArrayView<StringView
{ {
Buffer* buffer = open_file_buffer(file); Buffer* buffer = open_file_buffer(file);
if (not suffix_backup.empty()) if (not suffix_backup.empty())
write_buffer_to_file(*buffer, file + suffix_backup); write_buffer_to_file(*buffer, buffer->name() + suffix_backup);
apply_to_buffer(*buffer); apply_to_buffer(*buffer);
write_buffer_to_file(*buffer, file); write_buffer_to_file(*buffer, buffer->name());
buffer_manager.delete_buffer(*buffer); buffer_manager.delete_buffer(*buffer);
} }
if (not isatty(0)) if (not isatty(0))