-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding tree command to FogOS #85
base: main
Are you sure you want to change the base?
Conversation
merging to main
I can code review this |
I can code review this |
Added in new mkfs.c for testing |
I really like this project! The way the directory tree is displayed using graphs and symbols is very clear and intuitive. The code works impressively well for most cases, including recursive traversal with depth limits. The flags also can be combined and work together well without errors. Suggestions for Improvement: 2.The tree function opens the file descriptor multiple times when counting and printing files. To improve efficiency, it could handle both tasks in a single pass without reopening directories. High Level Checks: Code Checks: |
Comments:
I do think to improve efficiency you could potentially make some changes to how you process flags. As the earlier CR points out, runtime might be slow through the uses of recursively counting files/directories multiple times for one task, so a change I could recommend is making your status variables global. This way, you can check for them during your tree() and contains_valid_file() functions and hopefully get rid of the large while loop inside of tree() that seems to have the same or similar logic to contains_valid_file(). High Level Checks:
Code Checks:
|
This is a great rendition of the tree command and it supports a lot of options... great! Code doesn't quite follow xv6 conventions but is well organized. Going through the code:
When I view a tree with nested directories, the full path keeps getting printed. I have a small example:
To me, it makes more sense to show This brings me to the next issue I ran into: if I go deeper than 3 directories, this will crash, e.g., Overall, this is a cool idea and I really like how complete it is as far as options go. You can earn +0.25 with the fixes above. Great job! |
Team: Riya Mathur, Suhani Arora, Chandana Srinivas
This project is a command-line tool written in C that displays the directory structure in a tree-like format. It allows users to explore directories and subdirectories with options to filter files by extension, display file sizes, and show file and directory counts. Supports recursive traversal of directories.
Features:
/tree <directory>
- Display a directory tree structure for a given path (Default is.
which is the root directory)./tree . -F <file extension>
-Optionally filter files by their extension./tree . -S
- Optionally show the size of files in bytes./tree . -C
- Optionally count and display the number of files and directories in each directory./tree . -L <depth>
- Optionally limits the depth of the directory tree. Only shows directories and files up to the specified depth level.You could also multiple flags:
/tree . -C -L <depth>
- Shows the counts of files and limits the depth of the directory tree./tree . -S -F <file extension>
- Shows the file sizes in bytes and filters files by their extension.Since xv6 does not have directories by default, the updated mkfs.c will create two directories:
dir1
anddir2
within xv6 for more convenient recursive testing of directories.