Replace a snprintf with format in backup file name generation
This commit is contained in:
parent
9edeb08e3a
commit
64e0b6e3f8
11
src/file.cc
11
src/file.cc
|
@ -231,15 +231,10 @@ void write_buffer_to_backup_file(Buffer& buffer)
|
||||||
StringView dir, file;
|
StringView dir, file;
|
||||||
std::tie(dir,file) = split_path(path);
|
std::tie(dir,file) = split_path(path);
|
||||||
|
|
||||||
char pattern[PATH_MAX+1];
|
String pattern = dir.empty() ? format(".{}.kak.XXXXXX", file)
|
||||||
if (not dir.empty())
|
: format("{}/.{}.kak.XXXXXX", dir, file);
|
||||||
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());
|
|
||||||
|
|
||||||
int fd = mkstemp(pattern);
|
int fd = mkstemp(&pattern[0]);
|
||||||
if (fd >= 0)
|
if (fd >= 0)
|
||||||
{
|
{
|
||||||
write_buffer_to_fd(buffer, fd);
|
write_buffer_to_fd(buffer, fd);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user