Patrick Lewery Harris

Forest - A file tree utility

By Patrick Harris

License standard-readme compliant


Description

Forest is a small program used for viewing and searching the file tree. It is heavily inspired by the tree command and one of my assignments for CSC209 at UofT.

Install


$ git clone https://github.com/patrickleweryharris/forest.git
$ cd forest
$ make
              

Usage

Printing

To print the file tree for a specific directory use:

$./print_forest DIRECTORY
              

Where DIRECTORY is the relative path

Searching

Running search_forest will search the file tree for items that match your search criteria. Searches can be done by name, permissions, type or regex. Regex searches are a more sophisticated version of the name search.

$./search_forest MODE DIRECTORY {FILENAME/PERMS/FILETYPE} OCCURRENCES
              

Where MODE is the search mode you want to use, DIRECTORY is the relative path and OCCURRENCES is the maximum number of results you want displayed. Use ALL if you want all results.

Only one of FILENAME, PERMS or FILETYPE may be included, corresponding to the search mode.

Input FILENAME if searching by name or regex, PERMS if searching by perms and FILETYPE if searching by type.

Search modes:

                
#define NAME 0
#define PERM 1
#define TYPE 2
#define REGEX 3
              

Type Codes:


#define REGFILE 0
#define REGDIR 1
              

Examples:

./search_forest NAME . forest.c ALL
              

This search searches for files with the file name “forest.c” in the current directory

./search_forest PERM . 420 ALL
              

This search searches for files with permissions code 420 in the current directory

./search_forest TYPE . DIR ALL
              

This search searches for directories in the current directory

./search_forest REGEX  . forest ALL
              

This searches using regex ‘forest’, returning all items that contain ‘forest’ in the current directory

Contribute

PRs accepted.

Small note: If editing the Readme, please conform to the standard-readme specification.