The In-Memory File System (IMFS) is implemented as a command-line interface (CLI) application with a focus on simplicity and efficiency. The system is built using Java and Maven for project management. The primary data structures include in-memory representations of directories and files. This entire system is made using test driven development (TDD) method.
- Project Structure
- Features
- Setup and Installation
- Usage
- Data Structures
- Design Decisions
The IMFS supports the following file system operations:
- mkdir: Create a new directory.
- cd: Change the current directory.
- ls: List the contents of the current or specified directory.
- grep: Search for a pattern in a file (bonus feature).
- cat: Display the contents of a file.
- touch: Create a new empty file.
- echo: Write text to a file.
- mv: Move a file or directory to another location.
- cp: Copy a file or directory to another location.
- rm: Remove a file or directory.
To deploy this project run
git clone https://github.com/your-username/inmemoryfilesystem.git
cd inmemoryfilesystem
javac -cp src/main/java -d target src/main/java/inito/filesystem/*.java src/main/java/inito/filesystem/commands/*.java
java -cp target inito.filesystem.InMemoryFileSystem
The IMFS is a command-line application. After running the system, you can execute various commands to interact with the file system
Example Commands:
1. mkdir new_directory: Create a new directory named "new_directory."
2. cd new_directory: Change the current directory to "new_directory."
3. ls: List the contents of the current directory.
4. cat file.txt: Display the contents of "file.txt."
Refer to the Features section for a complete list of supported commands.
Directory Structure
The core of the In-Memory File System (IMFS) is modeled as a tree structure of directories, with each directory having references to its children (subdirectories and files). The primary attributes of the Directory class include:
public class Directory {
private String name;
private Map<String, Directory> directories;
private Map<String, File> files;
// Other attributes and methods
}
File Structure
Files are represented by the File class, which holds the content of the file along with other relevant attributes:
public class File {
private String name;
private String content;
// Other attributes and methods
}
Modularity: Implemented using the Command Design Pattern for extensibility.
In-Memory Storage: All file system data stored in memory for fast access.
Directory Structure: Hierarchical tree-like structure for effective navigation.