From 383c579db1994308d78836b5bfc6850aec31a64f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miskolczi=20Rich=C3=A1rd?= Date: Wed, 11 Jun 2025 13:17:05 +0200 Subject: [PATCH] Only append new line if file is not empty --- src/FileService.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/FileService.cpp b/src/FileService.cpp index b4bf937..a5a03b7 100644 --- a/src/FileService.cpp +++ b/src/FileService.cpp @@ -22,8 +22,13 @@ void FileService::createOrOverwriteFile(std::string path, std::string content) { }; void FileService::appendToFile(std::string path, std::string content) { + bool fileNotEmpty = FileService::doesNonEmptyFileExist(path); std::stringstream cmd; - cmd << ECHO_PATH << " \"" << "\n" << content << "\" >> " << path; + if (fileNotEmpty) { + cmd << ECHO_PATH << " \"" << "\n" << content << "\" >> " << path; + } else { + cmd << ECHO_PATH << " \"" << content << "\" >> " << path; + } ShellService::exec(cmd.str().c_str()); };