back to scratko.xyz
aboutsummaryrefslogtreecommitdiff

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

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

./file_finder README.md