Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create an application that takes in a path (relative or absolute) as well as an int and recursively prints out statistics about the files contained

Create an application that takes in a path (relative or absolute) as well as an int and recursively prints out statistics about the files contained in each subdirectory.

Your program should open each subdirectory (opendir).

For each file (readdir), gather the necessary stats (stat).

Each time it encounters a subdirectory, it should recurse.

The integer passed is the max number of files to parse in each directory.

Info to be printed for each file:

User ID of owner.

The % of the total memory in this directory the file takes up.

Number of seconds since last access (time).

void printStats(char* path, int max) {

// DO: Put code here.

}

int main(int argc, char** argv) {

if (argc < 3) {

printf("Wrong number of args, expected 2, given %d", argc - 1);

exit(1);

}

printStats(argv[1], atoi(argv[2]));

}

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

Big Data And Hadoop Fundamentals Tools And Techniques For Data Driven Success

Authors: Mayank Bhushan

2nd Edition

9355516665, 978-9355516664

Students also viewed these Databases questions