From dbd489ff257ef08556bb973af519563b34291610 Mon Sep 17 00:00:00 2001
From: Florian Fischer <florian.fischer@muhq.space>
Date: Wed, 21 Jul 2021 18:04:02 +0200
Subject: [PATCH] [fsearch] use emper IO instead of printf

---
 apps/fsearch/fsearch.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/apps/fsearch/fsearch.cpp b/apps/fsearch/fsearch.cpp
index 8ef73c0a..85ef09c1 100644
--- a/apps/fsearch/fsearch.cpp
+++ b/apps/fsearch/fsearch.cpp
@@ -1,10 +1,8 @@
 // SPDX-License-Identifier: LGPL-3.0-or-later
 // Copyright © 2021 Florian Fischer
 #include <fcntl.h>
-#include <sys/types.h>
 
 #include <array>
-#include <cstdio>
 #include <cstdlib>
 #include <cstring>
 #include <filesystem>
@@ -44,7 +42,10 @@ void search(const std::string& path) {
 	ssize_t bytes_read = emper::io::readFileAndWait(fd, buf.data(), buf.size(), bytes_searched);
 	while (bytes_read > 0) {
 		if (memmem(&buf[0], bytes_read, needle, needle_len)) {
-			printf("%s\n", path.c_str());
+			std::array<char, PATH_MAX + 1> outBuf;
+			memcpy(outBuf.data(), path.c_str(), path.length());
+			outBuf[path.length()] = '\n';
+			emper::io::writeFileAndWait(STDOUT_FILENO, outBuf.data(), path.length() + 1, 0);
 			goto out;
 		}
 
-- 
GitLab