From ee94d85a8c9bee7a507053dea9e75f27b396e36f Mon Sep 17 00:00:00 2001 From: Zy Date: Fri, 11 Oct 2024 23:12:55 +0200 Subject: [PATCH] dev: fix 'navigate' tester --- source/main.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index 908abcc..0b6dea3 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -409,7 +409,8 @@ navigate: dirent *dir_in; do { dir_in = readdir(dir); - cout << "> " << dir_in->d_name << endl; + if (dir_in) + cout << "> " << dir_in->d_name << endl; } while (dir_in); closedir(dir); } @@ -424,14 +425,12 @@ navigate: cout << "Content:" << endl; int n = 1; char buf[1000]; - while (n) + while (n > 0) { n = read(file, buf, 1000); if (n < 0) - { cout << "read() error :(" << endl; - } - if (n > 0) + else if (n > 0) write(1, buf, n); } cout << "[EOF]" << endl;