From b04388221d3b8421297fd669c5f2e241dbaa858a Mon Sep 17 00:00:00 2001 From: Florian Fischer <florian.fischer@muhq.space> Date: Mon, 21 Feb 2022 11:24:07 +0100 Subject: [PATCH] fsearch: write only found files to stdout and use implicit file offset In the emper-fs-eval I would like to validate the output of the fsearch variants against a list of known files. Not writing any log messages to stdout make that easier. Use -1 as the offset of the write to stdout. Passing offset -1 means to use the file's implicit offset just like write(2). When using a tty as stdout offset 0 is fine but when redirecting stdout to a file 0 will cause that previously found paths will always be overwritten. --- apps/fsearch/fsearch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/fsearch/fsearch.cpp b/apps/fsearch/fsearch.cpp index df2c8408..2093ca6d 100644 --- a/apps/fsearch/fsearch.cpp +++ b/apps/fsearch/fsearch.cpp @@ -51,7 +51,7 @@ void search(const std::string& path) { 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); + emper::io::writeFileAndWait(STDOUT_FILENO, outBuf.data(), path.length() + 1, -1); goto out; } @@ -105,9 +105,9 @@ static auto fssearch(const po::variables_map& vm) -> int { Runtime runtime; - std::cout << "Starting fsearch with stealingMode=" << stealingMode; - if (max_running) std::cout << " and " << max_running->getCount() << " file fibers"; - std::cout << std::endl; + std::cerr << "Starting fsearch with stealingMode=" << stealingMode; + if (max_running) std::cerr << " and " << max_running->getCount() << " file fibers"; + std::cerr << std::endl; auto* dirWalker = Fiber::from(walk_dir); runtime.scheduleFromAnywhere(*dirWalker); -- GitLab