Skip to content

Yugal006/FileSystemSimulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

🖥️ File System Simulator (Java CLI)

A Command Line Interface (CLI) based File System Simulator built in Java that mimics both a virtual file system and interacts with the real operating system file system.

This project demonstrates core Operating System concepts such as:

  • File & Directory Management
  • Disk Block Allocation
  • Tree Structures
  • Persistence using Serialization

🚀 Features

📁 Virtual File System

  • Create/Delete directories and files
  • Navigate using cd, pwd
  • Read & write file content
  • Tree structure visualization
  • File search (find)
  • Disk block allocation simulation
  • Persistent storage (save/load system state)

💻 Real File System (OS Interaction)

  • Browse real directories
  • Create/Delete real files & folders
  • Navigate system directories
  • Safe delete (prevents deleting non-empty folders)

⚡ Smart Features

  • Command auto-completion (auto)
  • Path-based suggestions (like terminal)
  • Color-coded output
  • Error handling for invalid commands
  • Disk usage visualization

🧠 Concepts Used

  • Tree Data Structure
  • File Allocation (Contiguous Allocation)
  • Serialization (ObjectOutputStream, ObjectInputStream)
  • Recursion (for find, tree)
  • CLI Command Parsing

📂 Project Structure

FileSystemSimulator/
│
├── cli/
│   └── CommandHandler.java
│
├── filesystem/
│   ├── FileSystem.java
│   └── FileNode.java
│
├── disk/
│   └── DiskManager.java
│
├── utils/
│   └── Colors.java
│
├── data/
│   └── filesystem.dat   (auto-created)
│
└── main/
    └── Main.java

⚙️ How to Run

1. Compile

javac -d out src/main/Main.java src/main/cli/*.java src/main/filesystem/*.java src/main/disk/*.java src/main/utils/*.java

2. Run

java -cp out main.Main

💾 Persistence (Save/Load)

  • System automatically loads previous state on start
  • System saves on exit
exit
→ System saved.

Data stored in:

/data/filesystem.dat

🧾 Commands

📁 Virtual File System

Command Description
mkdir Create directory
cd Change directory
cd .. Go back
ls List contents
pwd Show current path
touch Create empty file
create Create file with size
write Write content
cat Read file
rm Delete file/folder
disk Show disk usage
free Show free blocks
find Search file
tree Show structure

💻 Real File System

Command Description
real-pwd Show real path
real-ls List real directory
real-mkdir Create folder
real-touch Create file
real-rm Delete file/folder
real-cd Change directory

⚡ Utility

Command Description
auto Auto-complete
help Show commands
clear Clear screen
exit Save & exit

💽 Disk Simulation

  • Fixed number of blocks (default: 50)
  • Contiguous allocation strategy
  • Each file stores allocated block list
  • Disk rebuilt on system load

Example:

Disk Status:
[X][X][ ][ ][X]...

🧪 Example Usage

mkdir docs
cd docs
touch file1.txt
write file1.txt
cat file1.txt
disk
exit

⚠️ Limitations

  • No permissions system
  • No multi-user support
  • Simple allocation strategy only
  • No file compression

🔮 Future Improvements

  • Recursive delete (rm -r)
  • File rename / move (mv)
  • Copy files (cp)
  • Fragmentation simulation
  • Defragmentation feature
  • Command history (↑ ↓ keys)
  • Real TAB auto-complete

👨‍💻 Author

Yugal Mahajan


⭐ If you like this project

Give it a ⭐ on GitHub and feel free to contribute!

About

A Command Line Interface (CLI) based File System Simulator built in Java that mimics both a virtual file system and interacts with the real operating system file system.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages