├── FileSystem.cpp ├── LICENSE ├── README.md └── images ├── Capture1.JPG ├── Capture10.JPG ├── Capture2.JPG ├── Capture3.JPG ├── Capture4.JPG ├── Capture5.JPG ├── Capture6.JPG ├── Capture7.JPG ├── Capture8.JPG └── Capture9.JPG /FileSystem.cpp: -------------------------------------------------------------------------------- 1 | //FAT32 implementation in C++ 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | using namespace std; 11 | 12 | struct File 13 | { 14 | int size1; 15 | string name,type,file_time; 16 | int s_addr; 17 | }; 18 | 19 | File filenm[20]; 20 | File filenm_priority[10]; 21 | 22 | void disp(); 23 | 24 | int n=0,n1; 25 | void create(string name,int size1,string type) 26 | { 27 | int i; 28 | int p=0; 29 | int total_size=0; 30 | time_t now = time(0); 31 | string file_time = ctime(&now); 32 | if(size1>4096 || size1<0) 33 | cout<<"ERROR: Sorry,Can not Handle file of size greater than 4GB"<<"\n"; 34 | else 35 | { 36 | for(i=0;i=1;i--) 54 | { 55 | filenm[i]=filenm[i-1]; 56 | filenm[i].s_addr=total_size - filenm[i].size1; 57 | total_size=total_size-filenm[i].size1; 58 | } 59 | 60 | filenm[0].name=name; 61 | filenm[0].size1=size1; 62 | filenm[0].s_addr=0; 63 | filenm[0].type=type; 64 | filenm[0].file_time=file_time; 65 | n++; 66 | disp(); 67 | cout<<"\n"<<"File Added.."<<"\n"<<"\n"; 68 | } 69 | 70 | } 71 | } 72 | void del(string name) 73 | { 74 | string type; 75 | int p=0,i; 76 | int k[10]; 77 | for(i=0;i1) 103 | { 104 | cout<<"There are "<>type; 106 | int lm=0; 107 | for(i=0;i4096 || size1<0) 145 | cout<<"ERROR: Sorry,Can not Handle file of size greater than 4GB"<<"\n"; 146 | else 147 | { 148 | for(i=0;i=1;i--) 166 | { 167 | filenm_priority[i]=filenm_priority[i-1]; 168 | filenm_priority[i].s_addr=total_size - filenm_priority[i].size1; 169 | total_size=total_size-filenm_priority[i].size1; 170 | } 171 | 172 | filenm_priority[0].name=name; 173 | filenm_priority[0].size1=size1; 174 | filenm_priority[0].s_addr=0; 175 | filenm_priority[0].type=type; 176 | n1++; 177 | cout<<"\n"<<"File Added in priority list.."<<"\n"<<"\n"; 178 | } 179 | 180 | } 181 | } 182 | 183 | void defragment() 184 | { 185 | filenm[0].s_addr=0; 186 | for(int i=1;i>day_today1; 232 | 233 | int nmn=0; 234 | for(i=0;i>day_file1; 243 | if(month_file1>month_today1) 244 | { 245 | del_file_30(i); 246 | nmn++; 247 | } 248 | else 249 | { 250 | //Taking no. of days in month as 30 251 | if(month_file1>ch; 353 | cout<<"\n"; 354 | switch(ch) 355 | { 356 | case 1: 357 | { 358 | cout<<"Enter file Name:"; 359 | cin>>name; 360 | cout<<"Enter File Size:"; 361 | cin>>size1; 362 | cout<<"Enter File type:"; 363 | cin>>type; 364 | create(name,size1,type); 365 | break; 366 | } 367 | case 2: 368 | { 369 | cout<<"Enter file name which you want to delete:"; 370 | cin>>name; 371 | del(name); 372 | break; 373 | } 374 | case 3: 375 | { 376 | cout<<"Defragmentation in Progress.. Reseting all the addresses!"<<"\n"; 377 | defragment(); 378 | break; 379 | } 380 | case 4: 381 | { 382 | cout<<"\n"<<"Displaying the Application Files:"<<"\n"<<"\n"; 383 | disp(); 384 | break; 385 | } 386 | case 5: 387 | { 388 | //SYSTEM FILES AND THE USER CAN NOT DELETE THESE FILES. 389 | cout<<"Enter file Name:"; 390 | cin>>name; 391 | cout<<"Enter File Size:"; 392 | cin>>size1; 393 | cout<<"Enter File type:"; 394 | cin>>type; 395 | create_priority(name,size1,type); 396 | break; 397 | } 398 | case 6: 399 | { 400 | string password,choice1; 401 | cout<<"\n"<<"Do you Really want to see the System Files[y/n]:"; 402 | cin>>choice1; 403 | 404 | if(choice1=="y" || choice1=="Y'" || choice1=="Yes") 405 | { 406 | cout<<"\n"<<"Enter the Password if you want to see the System files:"; 407 | //Here password is admin 408 | cin>>password; 409 | if(password=="admin") 410 | disp_system_files(); 411 | else 412 | cout<<"\n"<<"Invalid Password!"<<"\n"<<"\n"; 413 | 414 | } 415 | break; 416 | 417 | } 418 | case 7: 419 | { 420 | cout<<"Enter the File Name: "; 421 | cin>>name; 422 | search_file(name); 423 | break; 424 | } 425 | case 8: 426 | { 427 | cout<<"Searching is progress.."<<"\n"<<"\n"; 428 | search_delete(); 429 | break; 430 | } 431 | case 9: 432 | { 433 | cout<<"Good Bye):"; 434 | break; 435 | } 436 | default: 437 | { 438 | cout<<"Invalid choice"<<"\n"; 439 | } 440 | 441 | } 442 | } 443 | 444 | return 0; 445 | } 446 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Vidit 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Analysis-of-File-System-and-implementation-of-FAT32-in-C++ 2 | Implementation of FAT32 File System in C++, and a project report on analysis of different File Systems. 3 | 4 | ## Further Reading 5 | In this project, I have implemented FAT32 File System in C++. You just need to copy the code written in FileSystem.cpp file 6 | in any of your IDE(Code Blocks, Geany ,Dev C++ etc). Don't choose Turbo C++ because the program is not compatible with it and it may show Error. 7 | 8 | In my File System implementation there are 9 different modules, 9 | 10 | ![](/images/Capture1.JPG) 11 | 12 | **1.Create a File :** In this module, the user need to Enter the Filename, Filesize and FileType.As we are implementing FAT32 so the file size should be less than 4GB(4096 MB) otherwise it will display an error message "Can not handle file of size greater then 4GB".Two files with same name can exist in the FileSystem but they should have different FileTypes otherwise it will display an error message. 13 | 14 | ![](/images/Capture2.JPG) 15 | 16 | **2.Delete a File:** In this module, the user need to Enter the filename and if file exists with the same it it will delete it and it more than one file exists with the same name then it will ask for filetype for more clerance and then it will delete it. 17 | 18 | ![](/images/Capture3.JPG) 19 | 20 | **3.Defragmentation:** In this module, The FileSystem is going to traverse the Starting Address and File Size of all the files and remove all the unallocated memory(which may occure because of File Deletion). Thus it helps in making the maximum use of the available memory. 21 | 22 | ![](/images/Capture4.JPG) 23 | 24 | **4.Display the Applicaiton Files:** It will display all the available files in the System. 25 | 26 | ![](/images/Capture5.JPG) 27 | 28 | **5.System Files Creation:** In this module, the user can create System Files which cannot be deleted and in order to see these files the user need to Enter a password. 29 | 30 | ![](/images/Capture6.JPG) 31 | 32 | **6.Display System Files:** First the user have to Enter the choice [y/n] and then it will ask for password (here the password is "admin"), Once the password got verified it will diaplay all the System Files. 33 | 34 | ![](/images/Capture7.JPG) 35 | 36 | **7.Search For a file:** The client can search for an Application File through this module. 37 | 38 | ![](/images/Capture8.JPG) 39 | 40 | **8.Delete of Files Older than 1 Month:** In this module the System will delete all the files older than 1 month and if incase no such File exists then it will display a message "All files are New". 41 | 42 | ![](/images/Capture9.JPG) 43 | 44 | **9.Exit:** With this module the user can Exit through the System loop. 45 | 46 | ![](/images/Capture10.JPG) 47 | 48 | 49 | 50 |

51 | Licensed under the [MIT License](LICENSE). 52 | -------------------------------------------------------------------------------- /images/Capture1.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture1.JPG -------------------------------------------------------------------------------- /images/Capture10.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture10.JPG -------------------------------------------------------------------------------- /images/Capture2.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture2.JPG -------------------------------------------------------------------------------- /images/Capture3.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture3.JPG -------------------------------------------------------------------------------- /images/Capture4.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture4.JPG -------------------------------------------------------------------------------- /images/Capture5.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture5.JPG -------------------------------------------------------------------------------- /images/Capture6.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture6.JPG -------------------------------------------------------------------------------- /images/Capture7.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture7.JPG -------------------------------------------------------------------------------- /images/Capture8.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture8.JPG -------------------------------------------------------------------------------- /images/Capture9.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viditgarg1999/Analysis-of-File-System-and-implementation-of-FAT32-in-C-/2ce28d44f88e31309485dffaf9350843521e14fb/images/Capture9.JPG --------------------------------------------------------------------------------