This code implements a Rust program that searches for files bigger than 100mb in a given directory or the whole file system if no filepath is given. It uses the clap
and std
libraries for command line argument parsing and file size calculation, respectively.
These guidelines will help you install and set up sizer on your system. Please follow these steps carefully to ensure a smooth installation process.
Before you begin, make sure your system meets the following prerequisites:
- Have Homebrew installed for Mac Users
-
Install Sizer
Depending on your operating system, follow the relevant installation method:
-
macOS:
brew tap BukiOffor/sizer brew install sizer
-
Windows:
- Download the installer. - Run the installer and follow the on-screen instructions.
-
Linux:
- Download the Linux package or use package manager commands (e.g., `apt`, `yum`) to install.
-
-
Configuration (if applicable)
Some software/tools may require configuration. Refer to the official documentation for details on how to configure sizer to suit your needs.
-
Verification
After installation, verify that sizer is installed correctly by running the following command:
sizer --version sizer -h
// Make sure you are in the project folder
// Run the program with a specific directory path
$ cargo run -q -- -p /path/to/directory
// Run the program without specifying a directory path (searches the whole file system)
$ cargo run -q
// Run the program with a specific directory path and custom file size threshold
$ cargo run -q -- -p /path/to/directory -s 200
matches
: Aclap::ArgMatches
object that contains the parsed command line arguments.
- Initialize the logger for logging purposes.
- Parse the command line arguments using
clap
to get thematches
object. - Get the value of the
path
argument from thematches
object. - If a
path
value is provided, convert it to aPathBuf
object and assign it tohome_dir
. - Get the value of the
size
argument from thematches
object. - If a
size
value is provided, assign it tosize
as anOption<&String>
. - If a
path
value is provided, call theentry
function from thesizer
library withhome_dir
andsize
as arguments. - If no
path
value is provided, create aPathBuf
object for the root directory ("/") and assign it toroot_dir
. - Call the
entry
function from thesizer
library withroot_dir
andsize
as arguments.
None. The function performs file size calculations and logging based on the provided command line arguments.