The File System Manager is a comprehensive implementation of a virtual file system. It provides a user-friendly interface in the command line for interacting with the file system, supporting a hierarchical structure with features such as:
- Adding, deleting, renaming, copying, and moving files and directories.
- Symbolic link management.
- Directory size calculation.
- DFS-based display of the file system structure.
Purpose:
- Serves as the entry point of the program.
Key Features:
- Includes
userIOControl.hpp
. - Contains a simple
main
function that calls therunner()
function. - Delegates all functional operations to the
runner()
function.
Purpose:
- Implements the core functionality of the File System Manager.
Description: Represents files or directories in the file system.
Attributes:
name
: Name of the file or directory.isFile
: Boolean flag differentiating files from directories.children
: A map storing child nodes for hierarchical traversal.size
: Integer storing file size (default is 0 for directories).symbolicLinks
: Vector to handle symbolic links to other nodes.
Constructor: Initializes node attributes based on input parameters.
Description: Represents the hierarchical structure of the file system.
Functionalities:
- Traversal:
- Implements DFS traversal to display the file system structure.
- Includes symbolic link representation.
- Insertion:
- Adds files or directories to the structure.
- Initializes attributes like
isFile
andsize
based on user input.
- Deletion:
- Deletes files or directories.
- Cleans up associated symbolic links.
- Search:
- Searches for files or directories by name.
- Includes symbolic link traversal in the search.
- Directory Size Calculation:
- Recursively computes the total size of a directory, including files and subdirectories.
- Symbolic Links:
- Supports adding symbolic links between nodes.
- Copy and Move Operations:
- Allows copying and moving files or directories within the structure.
- Renaming:
- Enables renaming of files or directories.
Helper Methods:
dfsHelper
: Implements recursive DFS traversal for displaying the file system.deleteNode
: Handles recursive deletion of nodes and their children.calculateDirectorySize
: Computes the total size of a directory.deepCopy
: Creates a deep copy of a file or directory for copy operations.
Purpose:
- Provides a user interface for managing the file system.
splitPath
: Splits a user-provided path string into components for hierarchical traversal.
displayMenu
: Displays a menu of available actions to the user.
Manages the interaction loop between the user and the file system.
Provides the following options:
- Display File System: Displays the hierarchical structure using DFS traversal.
- Add File/Directory: Prompts the user for details and inserts the item into the file system.
- Delete File/Directory: Deletes the specified file or directory.
- Search for File/Directory: Searches the file system by name.
- Calculate Directory Size: Computes the total size of a specified directory.
- Add Symbolic Link: Creates a symbolic link from one node to another.
- Copy File/Directory: Copies a file or directory to a new location.
- Rename File/Directory: Renames a file or directory.
- Move File/Directory: Moves a file or directory to a new location.
- Exit: Exits the program gracefully.
User Input Handling:
- Uses
cin
andgetline
to ensure proper handling of strings and integers.
- Compile the program:
g++ -o file_system_manager main.cpp fileSystem.cpp userIOControl.cpp
- Run the program:
./file_system_manager
This project is open-source and available for modification and distribution under the Apache-2.0 license.