1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-23 07:15:52 +03:00

Replace a snprintf with format in backup file name generation

This commit is contained in:
Maxime Coste 2015-04-02 13:58:06 +01:00
parent 9edeb08e3a
commit 64e0b6e3f8

View File

@ -231,15 +231,10 @@ void write_buffer_to_backup_file(Buffer& buffer)
StringView dir, file;
std::tie(dir,file) = split_path(path);
char pattern[PATH_MAX+1];
if (not dir.empty())
snprintf(pattern, PATH_MAX+1, "%s/.%s.kak.XXXXXX",
(const char*)dir.zstr(), (const char*) file.zstr());
else
snprintf(pattern, PATH_MAX+1, ".%s.kak.XXXXXX",
(const char*)file.zstr());
String pattern = dir.empty() ? format(".{}.kak.XXXXXX", file)
: format("{}/.{}.kak.XXXXXX", dir, file);
int fd = mkstemp(pattern);
int fd = mkstemp(&pattern[0]);
if (fd >= 0)
{
write_buffer_to_fd(buffer, fd);