Preparing your design workspace

Loading the problem and your saved attempt…

Design an In-Memory File System

Model an in-memory hierarchical file system with explicit path, entry, listing, and concurrency contracts.

For this exercise, assume a process-local file system supports mkdir(path), createFile(path), and ls(path). Paths are absolute, use slash separators, and reject dot, dot-dot, empty segments, and attempts to traverse through a file.

mkdir creates missing directories and is idempotent when the final directory already exists. createFile creates an empty regular file and fails on any existing entry. ls returns sorted child names for a directory and the basename for a file.

A base Entry abstraction has Directory and RegularFile variants, while one FileSystem coordinator owns the root and synchronization. File content, permissions, links, persistence, and cross-process sharing are outside scope.

Design the object model, public interfaces, operation interactions, errors, and a safe concurrency strategy without relying on one global collection of path strings.