Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MockOS

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.

Design Patterns

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

Highlights

  • 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

Tech Stack

  • C++14
  • CMake 3.20+
  • GoogleTest

Supported Commands

The interactive CLI currently wires up these commands:

  • touch <filename> creates a new file
  • touch <filename> -p creates a password-protected file
  • ls lists files in the file system
  • ls -m lists files with metadata
  • cat <filename> overwrites file contents through the prompt
  • cat <filename> -a appends to an existing file
  • ds <filename> displays formatted file contents
  • ds <filename> -d displays raw file contents
  • cp <source> <new_name_without_extension> clones a file
  • rm <filename> removes a file
  • rn renames a file through a macro command
  • tcd creates, edits, and displays a file through a macro command

Design Goals

  • Separate interface from implementation
  • Favor composition over inheritance
  • Make new commands and file types easy to add
  • Keep command execution independent from storage implementation

Architecture Notes

The main implementation is organized around a small set of collaborating abstractions:

  • AbstractFile, AbstractFileSystem, and AbstractFileFactory define the core file model
  • AbstractCommand and CommandPrompt power 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

Project Structure

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

Build

cmake -S . -B build
cmake --build build

This produces the main executable:

./build/src/mockos_cli

Run Tests

cmake --build build --target mockos_tests
./build/tests/mockos_tests

Note: the test configuration downloads GoogleTest during CMake configure, so the first build requires network access.

Example Session

$ 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

Why This Project

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.

About

An object-oriented mock operating system with commands, file abstractions, and design patterns

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages