Crates.io | file_info |
lib.rs | file_info |
version | 0.1.3 |
source | src |
created_at | 2024-11-18 11:39:40.340363 |
updated_at | 2024-11-21 01:11:26.230542 |
description | A Rust program that inspects a file and prints its metadata including file size and type. |
homepage | |
repository | |
max_upload_size | |
id | 1452117 |
size | 3,326 |
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.
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.
Ensure Rust is installed on your system. You can download it from rust-lang.org.
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
If the file example.txt exists, you'll see output similar to:
File Size: 123 bytes
File Type: Regular File
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.
This project is licensed under the MIT License
bensatlantik