Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a small library in C that parses files and directory structures to list files and directory contents recursively in a tree format, where each

Write a small library in C that parses files and directory structures to list files and directory contents recursively in a tree format, where each subdirectory is indented from the last. You will implement basic sorting and print the file permissions, username, group, and file size. Most of the code is written except for the TODO comments circled in red. Finish the code where TODO comments are shown below. For your answer number TODO 1-8 instead of writing out this entire file. Thanks

image text in transcribed

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

tdefine arrlen(a) \{sizeof(a) / sizeof (a) ) dprintf(...) can be used like printf to print diagnostic messages in the debug build. Does ifdef Debug \#define dprintf(...) fprintfistderr, __VA_ARGS _ ] telse *define /* We will need to pass around file stat info quite a bit, so let's make a struct for this purpose. struct fileinfo char *pathi struct stat st; * Nore: Notice how all of these functions and file-scope identifiers are declared static. This means they have no linkage. You should read the C language reference documents and the difference /* A few helper functions to break up the program static char *mode_string(mode_t mode): static void free_file_list(struct fileinfo **file_list, size_t file_count): static int filecmp(void const *lhs, void const *rhs); * some file-scoped static int depth: static struct tree_options opts: static int cur_dir=AT_FDCWD; f* Here are our two main functions. tree_print is the externaliy linked function, accessible to static int tree_print_recurse(struct fileinfo finfoli: extern int tree_print(char const *path, struct tree_options opts) opts = opts: depth =0; depth =0 : (lfinfo.path = strdup ( path) ) == NULL) goto exit: fifataticur_dir, path, ( finfo.st), NT_SYMLINK_NOFOLLOW) = = -1) goto exit; freelfinfo.path); 1 4.175

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Illuminated

Authors: Catherine Ricardo

2nd Edition

1449606008, 978-1449606008

More Books

Students also viewed these Databases questions

Question

Did you check photos for quality and rights clearance?

Answered: 1 week ago