Skip to content

Latest commit

 

History

History
80 lines (55 loc) · 2.84 KB

File metadata and controls

80 lines (55 loc) · 2.84 KB

Time-Traveling File System

This is a complete implementation of an in-memory, time-traveling file system.

Interactive Build & Run:

    bash compile.sh
    ./tfs

Build & Run for Quick Testing:

  • Create a file, say sample_input.txt with commands for testing.
  • Build using bash compile.sh
  • Run ./tfs > sample_input.txt

Project contents

  • main.cpp: Command-line interface and program entry.

  • tree.hpp: TreeNode structure for file versions.

  • file.hpp: File class holding version tree and operations.

  • filesystem.hpp: FileSystem class managing multiple files and analytics.

  • hashmap.hpp: Minimal separate-chaining HashMap implemented from scratch.

  • heap.hpp: BinaryMaxHeap generic max-heap.

  • compile.sh: Build script. Run bash compile.sh.

  • sample_input.txt: Example command sequence to try the system quickly.

Commands

See the interactive HELP inside the program for a similar list.

Major commands:

  • CREATE <filename> Create a new file with root version id = 0, empty content, and an initial snapshot message ("Initial root"). Root is immutable (snapshotted at creation).

  • READ <filename> Print the content of the file’s currently active version.

  • INSERT <filename> <content...> Append content. If active version is a snapshot, a new child version is created with appended content. Otherwise, the active version is edited in-place.

  • UPDATE <filename> <content...> Replace content. Follows the same snapshot semantics as INSERT.

  • SNAPSHOT <filename> <message...> Mark the active version as a snapshot; record message and timestamp. (A snapshotted version becomes immutable.)

  • ROLLBACK <filename> [versionID] If versionID is given, move the active pointer to that version. Otherwise, move to the parent of the current active version. Errors if already at root and no parent.

  • HISTORY <filename> List all snapshotted versions in chronological order (by snapshot timestamp). Each line:
    version_id <epoch_seconds> <message>

  • RECENT_FILES [num] List files in descending order of their last modification time. Each line:
    <filename> <epoch_seconds>

  • BIGGEST_TREES [num] List files in descending order of total version count. Each line:
    <filename> <count>

  • HELP Shows all the possible commands.

  • EXIT Quit the program.

Semantics & Notes

  • Root version (ID 0) is created as a snapshot with message Initial root.
  • Snapshotted versions are immutable. Editing while the active version is snapshotted creates a child version.
  • Version IDs start at 0 and increment per file.
  • HISTORY prints snapshotted versions in chronological order with epoch timestamps.
  • RECENT_FILES and BIGGEST_TREES accept an optional numeric argument to limit results.
  • Errors print as ERROR: ....