From 4a10046d2d172505e775c65ff984edf88f4a84d5 Mon Sep 17 00:00:00 2001 From: Abdellah El Morabit Date: Tue, 18 Feb 2025 15:41:57 +0100 Subject: tested the ls code seperatly and it worked --- ls | Bin 0 -> 33600 bytes ls.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100755 ls create mode 100644 ls.c diff --git a/ls b/ls new file mode 100755 index 0000000..dba7d6b Binary files /dev/null and b/ls differ diff --git a/ls.c b/ls.c new file mode 100644 index 0000000..876e60e --- /dev/null +++ b/ls.c @@ -0,0 +1,42 @@ +/* + * ===================================================================================== + * + * Filename: ls.c + * + * Description: + * + * Version: 1.0 + * Created: 02/18/2025 15:39:55 + * Revision: none + * Compiler: gcc + * + * Author: YOUR NAME (), + * Organization: + * + * ===================================================================================== + */ +#include +#include +#include + + +int main(){ + + char *path = "folder"; + struct dirent *entry; + DIR *dP = opendir(path); + + // check if the directory got opened successfully + if (dP == NULL) { + perror("opendir"); + return 1; + } + + // print the folder|directory name + while ((entry = readdir(dP)) != NULL) { + char *temporary_variable = entry->d_name; + printf("%s\n", entry->d_name); + } + closedir(dP); + +} -- cgit v1.2.3-70-g09d2