C++14 | CMake | GoogleTest | OOP | Design Patterns
MockOS is a modular in-memory file system and interactive command-line shell written in C++. It demonstrates object-oriented software architecture through an extensible file system, reusable command framework, and multiple classic design patterns. Originally developed as a university project, it has since been refactored into a polished portfolio application.
Overview: this project is a small but extensible C++ CLI application where users can create files, edit content, list directory state, display formatted output, clone files, remove files, and compose higher-level workflows through macro commands.
The main interactive CLI entry point is src/main.cpp, which builds to mockos_cli.
| Pattern | Usage |
|---|---|
| Command | Interactive shell commands |
| Abstract Factory | File creation |
| Visitor | Display formatting |
| Proxy | Password-protected files |
| Strategy | Macro command parsing |
| Prototype | File cloning |
| Macro Command | Multi-step command workflows |
- In-memory file system with support for text and image file types
- Designed a modular in-memory file system using abstract interfaces and dependency inversion
- Implemented a reusable command framework with macro command composition
- Applied multiple classic object-oriented design patterns to improve extensibility
- Built comprehensive GoogleTest unit tests covering file operations, command execution, and macro workflows
- C++14
- CMake 3.20+
- GoogleTest
The interactive CLI currently wires up these commands:
touch <filename>creates a new filetouch <filename> -pcreates a password-protected filelslists files in the file systemls -mlists files with metadatacat <filename>overwrites file contents through the promptcat <filename> -aappends to an existing fileds <filename>displays formatted file contentsds <filename> -ddisplays raw file contentscp <source> <new_name_without_extension>clones a filerm <filename>removes a filernrenames a file through a macro commandtcdcreates, edits, and displays a file through a macro command
- Separate interface from implementation
- Favor composition over inheritance
- Make new commands and file types easy to add
- Keep command execution independent from storage implementation
The main implementation is organized around a small set of collaborating abstractions:
AbstractFile,AbstractFileSystem, andAbstractFileFactorydefine the core file modelAbstractCommandandCommandPromptpower the interactive shell- Display behavior is decoupled from file implementations using the Visitor pattern
- A password proxy wraps files without changing their concrete implementations
- Macro commands orchestrate multiple commands through interchangeable parsing strategies
include/mockos/ Public interfaces and headers
lib/mockos/ Core library implementation
src/ Interactive CLI entry point
tests/ GoogleTest test suite
docs/ Iteration notes from the original course project
cmake -S . -B build
cmake --build buildThis produces the main executable:
./build/src/mockos_clicmake --build build --target mockos_tests
./build/tests/mockos_testsNote: the test configuration downloads GoogleTest during CMake configure, so the first build requires network access.
$ touch notes.txt
$ cat notes.txt
Enter data you would like to write to the file. Enter :wq to save the file and exit, enter :q to exit without saving.
hello from mockos
:wq
$ ls
notes.txt
$ ds notes.txt
hello from mockos
Rather than emulating a complete operating system, MockOS focuses on software architecture. The project demonstrates how abstract interfaces, design patterns, and command composition can be combined to build an extensible C++ application with clear separation of concerns.