Dash Engine - Filesystem/Networking Utilities
A simple library crate that provides utility functions for interacting with the filesystem, including creating, reading, and deleting files.
Features
- Create a file: Create a file in a specific directory, creating the directory if it doesn't exist.
- Read a file: Read the contents of a file from a specific directory.
- Delete a file: Delete a file from a specific directory.
Development Features
- Download a file: Download a file from the internet into an specific directory.
Installation
To add this crate as a dependency in your project, update your Cargo.toml file:
[]
= "0.1.1"
Replace "0.1.1" with the appropriate version if needed.
Usage
You can call the functions from the filesystem module to interact with the filesystem. Below are examples for each function.
Example 1: Create a File
To create a file, you can use the create_file function:
use create_file;
Example 2: Read a File
To read a file, use the read_file function:
use read_file;
Example 3: Delete a File
To delete a file, use the delete_file function:
use delete_file;
Function Documentation
create_file
;
Arguments:
directory: The path to the directory where the file should be created.file_name: The name of the file to create.
Returns:
Ok(())if the file is created successfully.Err(io::Error)if an error occurs.
read_file
;
Arguments:
directory: The path to the directory where the file is located.file_name: The name of the file to read.
Returns:
Ok(String)containing the file's content.Err(io::Error)if an error occurs.
delete_file
;
Arguments:
directory: The path to the directory where the file is located.file_name: The name of the file to delete.
Returns:
Ok(())if the file is deleted successfully.Err(io::Error)if an error occurs.
License
This project is licensed under the following license:
- MIT License
Contributing
- Fork the repository.
- Clone your fork locally.
- Create a new branch for your changes.
- Make your changes and add tests.
- Submit a pull request.
Additional Notes
- Ensure the provided directory paths are correct and the application has appropriate permissions to read/write files.
- The
create_filefunction creates the entire directory structure if it doesn't already exist (usingfs::create_dir_all). - The
read_filefunction reads the entire file content into aString. - The
delete_filefunction removes the specified file.