diff --git a/exercises/mycp/README.md b/exercises/mycp/README.md new file mode 100644 index 0000000..290ceb3 --- /dev/null +++ b/exercises/mycp/README.md @@ -0,0 +1,96 @@ +# ๐Ÿ“„ mycp โ€“ A Simple File Copy Utility in C + +`mycp` is a basic implementation of the Unix `cp` command written in C. +It copies the contents of one file into another, handling errors and signals safely. + +--- + +## ๐Ÿ“ฆ Project Structure + +``` +mycp/ +โ”œโ”€โ”€ mycp.c # Main program source +โ”œโ”€โ”€ Makefile # Build and test automation +โ””โ”€โ”€ test/ + โ””โ”€โ”€ run_tests.sh # Automated test and Valgrind report +``` + +--- + +## โš™๏ธ Build Instructions + +To compile the program: + +```bash +make +``` + +To clean up build files: + +```bash +make clean +``` + +To remove test artifacts as well: + +```bash +make distclean +``` + +--- + +## ๐Ÿงช Running Tests + +The test script: + +- Creates temporary test files +- Runs `mycp` and compares results with `cmp` +- Uses **Valgrind** to check for memory issues + +Run the tests with: + +```bash +make test +``` + +--- + +## ๐Ÿš€ Usage + +```bash +./mycp SOURCE DEST +``` + +- `SOURCE`: Path to the file to copy from. +- `DEST`: Path to the file to copy to. + +Example: + +```bash +./mycp input.txt output.txt +``` + +--- + +## ๐Ÿง  Learning Objectives + +- Open/read/write/close file descriptors +- Use of `open(2)`, `read(2)`, `write(2)`, and `close(2)` +- Error handling (`perror`, `errno`) +- Use of `Makefile` and basic testing with shell scripts +- Optional: use of `lseek` for advanced length computation + +--- + +## โœ… Requirements + +- GCC (C11) +- POSIX-compliant system (Linux, macOS) +- [Valgrind](https://valgrind.org/) for memory leak analysis (optional, used in tests) + +--- + +## ๐Ÿ“„ License + +Educational use only. No license required. + diff --git a/exercises/tree/README.md b/exercises/tree/README.md new file mode 100644 index 0000000..34fc40d --- /dev/null +++ b/exercises/tree/README.md @@ -0,0 +1,107 @@ +# ๐Ÿ—‚๏ธ tree โ€“ Directory Tree Viewer in C + +A simplified implementation of the Unix `tree` command in C. +This utility recursively traverses a directory and prints its structure in a tree-like format. + +--- + +## ๐Ÿ“ฆ Project Structure + +``` +tree/ +โ”œโ”€โ”€ main.c # Entry point +โ”œโ”€โ”€ tree.c # Directory traversal logic +โ”œโ”€โ”€ tree.h # Function declarations +โ”œโ”€โ”€ Makefile # Build & test automation +โ””โ”€โ”€ test/ + โ””โ”€โ”€ run_tests.sh # Automated tests + Valgrind +``` + +--- + +## โš™๏ธ Build Instructions + +To compile the program: + +```bash +make +``` + +To clean up build files: + +```bash +make clean +``` + +To remove test artifacts as well: + +```bash +make distclean +``` + +--- + +## ๐Ÿงช Running Tests + +The test script: + +- Creates a temporary directory structure +- Runs the program and compares its output to the expected result +- Performs memory leak analysis with **Valgrind** + +To run all tests: + +```bash +make test +``` + +--- + +## ๐Ÿš€ Usage + +```bash +./tree [DIRECTORY] +``` + +If no directory is specified, the current directory (`.`) is used. + +Example: + +```bash +./tree testdir +``` + +Sample output: + +``` +|-- file1.txt +|-- sub1 + |-- file2.txt +|-- sub2 + |-- file3.txt +``` + +--- + +## ๐Ÿง  Learning Objectives + +- Use of `opendir`, `readdir`, and `closedir` to iterate directories +- Handling file paths and recursion +- Working with `stat` to detect subdirectories +- Implementing simple CLI programs in C +- Using `Makefile` and Valgrind for tooling and quality + +--- + +## โœ… Requirements + +- GCC (C11) +- POSIX-compliant system (Linux, macOS) +- [Valgrind](https://valgrind.org/) for memory checking (optional, used in tests) + +--- + +## ๐Ÿ“„ License + +Educational use only. No license required. +