How mohit-s96/fs-utils works
Main Components
• Entry Point & CLI Parser: The main.c file and cli.c/h implement the CLI parser responsible for reading user input and dispatching commands.
• Command Handlers: Individual commands are split across separate source files:
• ls (ls.c)
• find (find.c)
• cp (copy.c)
• new (new.c)
• size (size.c)
• Testing: The tests directory containing tests/test.c houses unit or integration tests for the CLI utilities.
• Build & Deployment: Makefile provides the build commands, installation, and test running instructions.
Relationships and Interactions
• The main entry (from main.c) initializes the CLI parser (from cli.c) which then routes to the correct command handler based on the user’s input.
• Each command handler (ls, find, cp, new, size) encapsulates the logic for that particular command, using shared utilities (such as multi-threading support from threads.c/h and pattern matching from pattern.c/h) when needed.
• The Makefile serves as the build orchestrator, compiling sources, running tests, and managing the installation process.
• The test suite invokes various parts of the code base to ensure correctness of functionalities.
Architectural Patterns and Design Principles
• Modular Design: The system is neatly divided by commands and common utility modules.
• Separation of Concerns: The CLI parser is separated from the individual command implementations, providing a clean boundary between input handling and file operations.
• Multi-threading: Some commands (find, cp, and du-like operations in size) have multi-threaded support, which implies components related to thread management (threads.c, threads.h) and possibly resource pooling (arena.c, arena.h).
• Extensibility: By separating commands into individual modules, it’s easier to add or modify functionalities without affecting the overall system.
Relevant Technologies, Frameworks, or Libraries
• C as the programming language.
• POSIX system calls for file operations.
• Likely use of pthreads for multi-threading (implied by threads.c/h).
• Standard C libraries for string, file, and I/O operations.
• The Make build system for building, testing, and installing the utility.