aboutsummaryrefslogtreecommitdiffstats
path: root/csci4061/101220_breakout
diff options
context:
space:
mode:
authorMatthew Strapp <msattr@gmail.com>2020-10-19 07:55:41 -0500
committerMatthew Strapp <msattr@gmail.com>2020-10-19 07:55:41 -0500
commit89ba57eb2b9e024996da29ba5e429adf15b27a6d (patch)
tree2edbdec54f9316c0110cab2aeaa599ce1dc14dee /csci4061/101220_breakout
parentadd new breakout (diff)
downloadhomework-89ba57eb2b9e024996da29ba5e429adf15b27a6d.tar
homework-89ba57eb2b9e024996da29ba5e429adf15b27a6d.tar.gz
homework-89ba57eb2b9e024996da29ba5e429adf15b27a6d.tar.bz2
homework-89ba57eb2b9e024996da29ba5e429adf15b27a6d.tar.lz
homework-89ba57eb2b9e024996da29ba5e429adf15b27a6d.tar.xz
homework-89ba57eb2b9e024996da29ba5e429adf15b27a6d.tar.zst
homework-89ba57eb2b9e024996da29ba5e429adf15b27a6d.zip
add breakouts
Diffstat (limited to 'csci4061/101220_breakout')
-rw-r--r--csci4061/101220_breakout/exercise.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/csci4061/101220_breakout/exercise.c b/csci4061/101220_breakout/exercise.c
index 5021142..be8bb11 100644
--- a/csci4061/101220_breakout/exercise.c
+++ b/csci4061/101220_breakout/exercise.c
@@ -9,9 +9,10 @@
#include <string.h>
int numOfEntries(char* path) {
- /*
- Count the number of entries in path
- */
+ int entries = 0;
+ while (readdir(path) != NULL) {
+ entries++;
+ } return entries;
}
int main(int argc, char** argv){
@@ -27,7 +28,20 @@ int main(int argc, char** argv){
return -1;
}
struct dirent* entry;
-
+ DIR* current = dir;
+
+while ((entry = readdir(dir)) != NULL) {
+ if (entry->d_type == "DT_DIR"){
+ printf("Directory: %s\n", entry->d_name);
+ printf(" Entries: %d\n", numOfEntries(entry));
+ } else if (entry->d_type == "DT_REG") {
+ printf("Regular File: %s\n", entry->d_name);
+ printf(" Owner: %d\n");
+ printf(" Size: %f\n");
+ } else {
+ printf("%s\n", entry -> d_name);
+ }
+ }
/*
Iterate through the elements in argv[1]
Refer the ls example in slides if you have any doubts