Giter VIP home page Giter VIP logo

file-mgmt-sys's Introduction

In-Memory FileSystem

A object oriented implementation of a file system using the Directory and File classes. The file system supports basic operations such as creating directories, navigating through the file system, listing directories, creating and copying files, and more. This program uses python str, dictionaries and lists to implement the Directory class and file class

Implementation Details

Directory Class

The Directory class represents a directory in the file system. It has name for the name of directories and uses str, subdirs for the list of subdirectories and uses Dictionaries, files for the list of files and uses Dictionaries

FileSystem Class

The FileSystem class serves as an interface for the file system and provides methods to interact with it. It includes methods such as mkdir, cd, ls, cp, mv, rm, touch, cat, and echo.

File Class

The File class represents a text file with a name and content. It has a clone method to create a deep copy of the file.

Usage

  1. Ensure you have Python installed on your system.

  2. Run the main.py file to start the file system interface.

  3. Use commands like mkdir, cd, ls, cp, mv, rm, touch, cat, and echo to interact with the file system.

  4. Optionally, use the save_state and load_state commands to save and load the file system state.

Example Usage

#FOR running only on BASH
# if you don't want to load prev state and save curr state
python main.py '{"save_state": true, "load_state":false, "path": "data.json"}'
# if you want to load prev state an d save curr state
python main.py '{"save_state": true, "load_state":true, "path": "data.json"}'
# if you want to load prev state
python main.py '{"save_state": true, "load_state":true, "path": "data.json"}'
# if you don't want to save prev state and don't want to load prev state
python main.py
#FOR running only on cmd
python main.py "{\"save_state\": true, \"load_state\":true,  \"path\": \"data.json\"}"

Example

  1. Creating a new directory:

    mkdir new_dir
  2. Changing directory:

    cd new_dir
  3. Listing directories:

    ls
  4. Copying a directory:

    cp src_dir target_dir
  5. Moving a file:

    mv src_file.txt target_dir
  6. Removing a directory:

    rm dir_to_remove
  7. Adding a new text file:

    touch new_file.txt
  8. Reading the content of a text file:

    cat existing_file.txt
  9. Writing content to a text file:

    echo existing_file.txt
    Input: "Hello World"
  10. Exiting the file system:

    exit

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.