Do not print "." and ".." while printing available commands

This commit is contained in:
SeekBytes
2022-04-30 15:39:14 +02:00
committed by GitHub
parent 0130725518
commit 50264d439f
+7 -4
View File
@@ -19,10 +19,13 @@ int main(int argc, char *argv[])
dirent_t dent;
int per_line = 0;
while (getdents(fd, &dent, sizeof(dirent_t)) == sizeof(dirent_t)) {
printf("%10s ", dent.d_name);
if (++per_line == 6) {
per_line = 0;
putchar('\n');
// Shows only regular files
if(dent.d_type == DT_REG){
printf("%10s ", dent.d_name);
if (++per_line == 6) {
per_line = 0;
putchar('\n');
}
}
}
putchar('\n');