This is a complete implementation of an in-memory, time-traveling file system.
bash compile.sh
./tfs- Create a file, say
sample_input.txtwith commands for testing. - Build using
bash compile.sh - Run
./tfs > sample_input.txt
-
main.cpp: Command-line interface and program entry. -
tree.hpp:TreeNodestructure for file versions. -
file.hpp:Fileclass holding version tree and operations. -
filesystem.hpp:FileSystemclass managing multiple files and analytics. -
hashmap.hpp: Minimal separate-chainingHashMapimplemented from scratch. -
heap.hpp:BinaryMaxHeapgeneric max-heap. -
compile.sh: Build script. Runbash compile.sh. -
sample_input.txt: Example command sequence to try the system quickly.
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 asINSERT. -
SNAPSHOT <filename> <message...>Mark the active version as a snapshot; record message and timestamp. (A snapshotted version becomes immutable.) -
ROLLBACK <filename> [versionID]IfversionIDis 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> -
HELPShows all the possible commands. -
EXITQuit the program.
- 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.
HISTORYprints snapshotted versions in chronological order with epoch timestamps.RECENT_FILESandBIGGEST_TREESaccept an optional numeric argument to limit results.- Errors print as
ERROR: ....