back to scratko.xyz
aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 2b1dfa5fe51c7d3f64ce91de773457229fdf98d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Recursive File Finder

This is a simple command-line utility written in C that recursively searches for
files or directories by name starting from the current directory (`./`). 

## Features

- Recursive search through all subdirectories.
- Supports searching for both files and directories by exact name.
- Dynamically grows internal buffer to handle deep directory structures.
- Prints full relative paths to all matching entries.
- Minimal dependencies, uses POSIX directory APIs (`opendir`, `readdir`, etc).

## How It Works

- Starts scanning from the current directory (`./`).
- For each directory entry, checks if the name matches the target.
- If a directory is found (other than `.` and `..`), descends recursively.
- Uses a dynamically allocated buffer to build relative paths during recursion.
- Prints the relative path to each found file or directory matching the input name.

## Limitations

- Only searches relative to the directory where the program is run.
- Matches are case-sensitive.
- No support for symbolic links or special file types.
- Does not support wildcards or partial matches.

## Usage

```bash
git clone https://git.scratko.xyz/file-finder
cd file-finder
gcc -Wall file_finder.c -o file_finder
./file_finder <name_to_search>
```
### Example

```bash
./file_finder README.md
```