#file-metadata #unix #filesize #rust

app file_info

A Rust program that inspects a file and prints its metadata including file size and type

4 releases

0.1.3 Nov 21, 2024
0.1.2 Nov 18, 2024
0.1.1 Nov 18, 2024
0.1.0 Nov 18, 2024

#180 in Filesystem

Download history 346/week @ 2024-11-15 70/week @ 2024-11-22 3/week @ 2024-11-29 17/week @ 2024-12-06

436 downloads per month

MIT license

4KB

file_info

Overview

This program demonstrates how to inspect file metadata using the Rust standard library. It reads the metadata of a specified file and prints details such as the file size and type.

How It Works

The program uses the fs::metadata function to get metadata information about the specified file. It checks if the given path is a regular file, a directory, or another type. It prints the file size (in bytes) and its type to the terminal.

Running the Program

Ensure Rust is installed on your system. You can download it from rust-lang.org.

Setup

Clone the repository:

git clone <repository-url>
cd file_info

Create a file named example.txt in the project directory or modify the filename in the code to match an existing file. Build and run the program:

cargo run

Expected Output

If the file example.txt exists, you'll see output similar to:

File Size: 123 bytes
File Type: Regular File

Notes

This program is designed to be run in the terminal. It currently works on Unix-based systems due to its use of MetadataExt from std::os::unix.

License

This project is licensed under the MIT License

Author

bensatlantik

No runtime deps