This project is a simple file system simulation written in C, allowing you to create directories and files, navigate between directories, and perform various file operations. The simulation mimics basic file system functionality, including directory management, file creation, editing, and copying.
-
Directory Operations:
- Create directories.
- Change directories.
- List files in the current directory.
- Navigate back to the parent directory.
-
File Operations:
- Create new files with random sizes.
- Edit file contents.
- Copy files between directories.
- Display file contents and metadata (size, creation date, modification date).
- Retrieve and print the absolute or relative path of the current directory.
File
struct: Represents a file with attributes such as name, size, data, creation date, and modification date.Directory
struct: Represents a directory containing files and subdirectories, and has a reference to its parent directory.FileSystem
struct: Represents the entire file system, starting with the root directory.
-
Clone the repository:
git clone https://github.com/yourusername/filesystem-simulation.git cd filesystem-simulation
-
Compile the code:
gcc -o filesystem filesystem.c
-
Run the executable:
./filesystem
- Create Directory: Create a new directory within the current directory.
- Create File: Create a new file within the current directory.
- Change Directory: Change the current directory to a specified directory or go back to the parent directory.
- List Files in Current Directory: Display all files and subdirectories in the current directory.
- Present Working Directory: Display the absolute path of the current directory.
- Print Relative Path: Display the relative path from the root to the current directory.
- File Actions:
- Open a file.
- Edit file contents.
- Copy a file to another directory.
- Display file contents.
- Display file metadata.
- Exit: Exit the program.
-
Creating a Directory:
Enter directory name: Documents Directory 'Documents' created successfully.
-
Creating a File:
Enter file name: myfile.txt File 'myfile.txt' created successfully. Size: 512 bytes
-
Editing a File:
Enter the contents you want to add: Hello, world! File edited successfully.
-
Copying a File:
Enter destination directory name: Documents File copied successfully.
This project is licensed under the MIT License - see the LICENSE file for details.