Giter VIP home page Giter VIP logo

rfm's Introduction

Rust File Manager

License: MIT Build Status Crates.io Status Docs

File manager, only inside Rust ๐Ÿฆ€

rfm is a convenient and intuitive way to interact with files on OS. Function naming is similar to Unix commands (ls, mkdir, mv, rm, cp, touch etc.), so you can easily figure out how to use it.

Installation

Add the latest rfm version to your Cargo.toml:

[dependencies]
rfm = "X.Y.Z" #replace it with the current version

Usage

For example:

extern crate rfm;
use std::{
    io::Result,
    path::{Path, PathBuf},
};

fn main() -> Result<()> {
    let dir_from_1 = Path::new("./foo").to_path_buf();
    let dir_from_2 = Path::new("./bar").to_path_buf();

    let dir_to = Path::new("./baz").to_path_buf();

    // check dir for existing files/dirs
    if rfm::ls(&dir_to)?.len() > 0 {
        // clean dir
        rfm::clean(&vec![&dir_to])?;
    }

    let need_to_move: Vec<&PathBuf> = vec![&dir_from_1, &dir_from_2];
    // Move some files/dirs
    rfm::mv(&need_to_move, &dir_to)?;

    Ok(())
}

Functions:

Function Description
rfm::ls Read the directory/directories and return the content. dir - takes the path to the directory whose contents you want to retrieve.
rfm::clean Clears the directory/directories of all child files and directories on the passed path. paths - takes a list of paths of what you want to clean.
rfm::mkdir Creates a directory/directories on the passed path. Note, the function creates all missing directories if they occur in the passed parameter. dir_paths - takes a list of paths of what you want to create.
rfm::touch Creates a file/files in the passed path. file_paths - takes a list of paths of what you want to create.
rfm::cp Copies files and directories, including nested files and directories. from - takes a list of paths of what you want to copy. to - destination path.
rfm::mv Moves files and directories, including nested files and directories. from - takes a list of paths of what you want to copy. to - destination path.
rfm::rm Deletes files/directories (including nested files/directories). from - takes a list of paths of what you want to delete.
rfm::extract Extracts all files from the directory, including nested files. from - takes a list of paths of where you want to extract files from. to - destination path.
rfm::get_size Returns the size of a file or directory in bytes, path - the path to the directory/file whose size you want to get.

License

MIT


Stay Rusty ๐Ÿฆ€

Made by Dmitry Shatokhin with love โค๏ธ

rfm's People

Contributors

dmtrshat avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

sahwar griefgeek

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.