fork download
  1. #include<iostream>
  2. #include<vector>
  3. #include<set>
  4. #include<string>
  5. #include<math.h>
  6. #include<fstream>
  7. #include<stdio.h>
  8. #include<stdlib.h>
  9. #include<string.h>
  10. #include <filesystem>
  11. #include <experimental/filesystem>
  12. #include"Text.h"
  13. #include<map>
  14. using namespace std;
  15. struct DirectoryEntry;
  16. struct DirectoryCluster;
  17. struct DataCluster;
  18. struct DataCluster {
  19. bool used;
  20. DataCluster* nxt;
  21. char data[30]; //caused error
  22. DataCluster() {
  23. nxt = NULL;
  24. used = 0;
  25. }
  26. };
  27. struct DirectoryEntrey {
  28. char name[300];
  29. unsigned long long size;
  30. DataCluster* starting_cluster;
  31. DirectoryCluster *next;
  32. };
  33. struct DirectoryCluster {
  34. vector<DirectoryEntrey> directory_entres;
  35. DirectoryCluster *prev;
  36. };
  37. //DataCluster arr[30000000];
  38. map<pair<DirectoryCluster*,char*>,int> mp;
  39. DataCluster* arr = new DataCluster;
  40. class FileSystem {
  41. private:
  42. unsigned long long ids, emp, all_size;
  43. DirectoryCluster* root; // we start from directory cluster root
  44. DirectoryCluster* cur;
  45. DirectoryEntrey* temp_holding_file;
  46. DirectoryCluster* source_folder;
  47. DirectoryCluster* distination_folder;
  48. string folder_name;
  49. bool file_hold;
  50. bool folder_hold;
  51. bool cut_flag;
  52. public:
  53. FileSystem() {
  54. source_folder = new DirectoryCluster;
  55. distination_folder = new DirectoryCluster;
  56. temp_holding_file = NULL;
  57. source_folder = NULL;
  58. distination_folder = NULL;
  59. file_hold = 0;
  60. folder_hold = 0;
  61. ids = 0;
  62. cut_flag = 0;
  63. folder_name = "";
  64. cur = root;
  65. //emp = 30000000;
  66. //arr =(DataCluster*)malloc(71582788* sizeof(DataCluster));
  67. }
  68. string get_folder_name() {
  69. return folder_name;
  70. }
  71. string get_file_system(char* path) {
  72. string p = path;
  73. for (int i = 0; i < p.size(); i++) {
  74. if (p[i] == ':')
  75. return p.substr(0, i);
  76. }
  77. return "N";
  78. }
  79. void link(DirectoryCluster*& parent, DirectoryCluster*& child , char* name) { //link two folders
  80. DirectoryEntrey* t = new DirectoryEntrey;
  81. strcpy(t->name, name);
  82. t->starting_cluster = NULL;
  83. t->next = child;
  84. parent->directory_entres.push_back(*t);
  85. child->prev = parent;
  86. }
  87. bool is_folder(string str) {
  88. char* n = (char*)malloc(300 * sizeof(char));
  89. strcpy(n, str.c_str());
  90. for (int i = 0; i < cur->directory_entres.size(); i++) {
  91. if (strcmp(n, cur->directory_entres[i].name) == 0) {
  92. if (cur->directory_entres[i].starting_cluster == NULL)
  93. return 1;
  94. return 0;
  95. }
  96. }
  97. return 0;
  98. }
  99. bool is_folder(string str, DirectoryCluster* current) {
  100. char* n = (char*)malloc(300 * sizeof(char));
  101. strcpy(n, str.c_str());
  102. for (int i = 0; i < current->directory_entres.size(); i++) {
  103. if (strcmp(n, current->directory_entres[i].name) == 0) {
  104. if (current->directory_entres[i].starting_cluster == NULL)
  105. return 1;
  106. return 0;
  107. }
  108. }
  109. }
  110. void move_to_loc(char* name, DirectoryCluster*& current) {
  111. bool ok = 0;
  112. for (int i = 0; i < current->directory_entres.size(); i++) {
  113. if (strcmp(current->directory_entres[i].name , name) == 0) {
  114. current = current->directory_entres[i].next;
  115. ok = 1;
  116. break;
  117. }
  118. }
  119. if (!ok)
  120. cout << " Directory NotFound" << endl;
  121. }
  122. void creat_folder(char* f_name, DirectoryCluster*& p) {
  123. //cout << f_name << endl;
  124. DirectoryEntrey* t1 = new DirectoryEntrey;
  125. DirectoryCluster* temp = new DirectoryCluster;
  126.  
  127. temp->prev = p;
  128. strcpy(t1->name, f_name); t1->starting_cluster = NULL; t1->next = temp;
  129. p->directory_entres.push_back(*t1);
  130. }
  131. void creat_folder(char* f_name) {
  132. DirectoryEntrey* t1 = new DirectoryEntrey;
  133. DirectoryCluster* temp = new DirectoryCluster;
  134. temp->prev = cur;
  135. strcpy(t1->name, f_name); t1->starting_cluster = NULL; t1->next = temp;
  136. cur->directory_entres.push_back(*t1);
  137. }
  138. bool move_to(string f_name) {
  139. bool f = 0;
  140. for (int i = 0; i < cur->directory_entres.size(); i++) {
  141. if (cur->directory_entres[i].name == f_name) {
  142. if (cur->directory_entres[i].next != NULL) {
  143. cur = cur->directory_entres[i].next;
  144. f = 1;
  145. break;
  146. }
  147. }
  148. }
  149. if (!f)
  150. return 0;
  151. return 1;
  152. }
  153. bool is_path(char* path) {
  154. string str = path;
  155. for (int i = 0; i < str.size(); i++) {
  156. if (str[i] == '\\')
  157. return 1;
  158. }
  159. return 0;
  160. }
  161. void print_path(DirectoryCluster* p) {
  162.  
  163. }
  164. void print_path() {
  165. }
  166. void move_back() {
  167. if (cur == root) {
  168. cout << "Cannot move back" << endl;
  169. }
  170. else
  171. cur = cur->prev;
  172. }
  173. void move_back(DirectoryCluster*& p) {
  174. p = p->prev;
  175. }
  176. void print_dir() {
  177. for (int i = 0; (unsigned long long) i < cur->directory_entres.size(); i++) {
  178. if (cur->directory_entres[i].starting_cluster != NULL)
  179. cout << cur->directory_entres[i].name << " " << "\t" << cur->directory_entres[i].size / (1024 * 1024) << "MB" << endl;
  180. else
  181. cout << cur->directory_entres[i].name << endl;
  182. }
  183.  
  184. }
  185. DataCluster* internal_read(DataCluster* s, unsigned long long& size) {
  186. DataCluster* start = new DataCluster;
  187. start = s;
  188. DataCluster* first_cluster = new DataCluster;
  189. DataCluster* prev_cluster = new DataCluster;
  190. unsigned long long i;
  191. if (emp >= ceil(size / 30)) {
  192. bool first = 1;
  193. for (i = 0; i <= all_size && start != NULL; i++) {
  194. if (first && arr[i].used == 0) {
  195. emp--;
  196. memcpy(arr[i].data, start->data, sizeof(arr[i].data));
  197. first = 0;
  198. first_cluster = prev_cluster = &arr[i];
  199. arr[i].nxt = NULL;
  200. start = start->nxt;
  201. arr[i].used = 1;
  202. }
  203. else if (arr[i].used == 0 && !first) {
  204. emp--;
  205. memcpy(arr[i].data, start->data, sizeof(arr[i].data));
  206. prev_cluster->nxt = &arr[i];
  207. arr[i].nxt = NULL;
  208. prev_cluster = &arr[i];
  209. arr[i].used = 1;
  210. start = start->nxt;
  211. }
  212. }
  213. return first_cluster;
  214. }
  215. else {
  216. cout << "No size" << endl;
  217. return NULL;
  218. }
  219. }
  220. DataCluster* read(char* path, unsigned long long& size) {
  221. //char buff[30];
  222. FILE* file = fopen(path, "rb");
  223. if (!file) {
  224. cout << "Falid" << endl;
  225. return NULL;
  226. }
  227. fseek(file, 0, SEEK_END); //move to the end of file
  228. unsigned long long n = ftell(file); // the current position of file
  229. size = n;
  230. fseek(file, 0, SEEK_SET);
  231. bool first_pos = 1;
  232. int sz;
  233. DataCluster* first_adress = new DataCluster;
  234. DataCluster* prev_block = new DataCluster;
  235. unsigned long long i;
  236. if (emp >= ceil(n / 30)) {
  237. for (i = 0; i < all_size; i++) {
  238. if (first_pos && arr[i].used == 0) {
  239. if ((sz = fread(arr[i].data, 1, sizeof(arr[i].data), file)) != 0) {
  240. first_adress = prev_block = &arr[i];
  241. arr[i].nxt = NULL;
  242. first_pos = 0;
  243. arr[i].used = 1;
  244. emp--;
  245. //if (sz < 30) break;
  246. }
  247. else {
  248. break;
  249. }
  250. }
  251. else {
  252. if (arr[i].used == 0 && !first_pos) {
  253. if ((sz = fread(arr[i].data, 1, sizeof(arr[i].data), file)) != 0) {
  254. arr[i].nxt = NULL;
  255. prev_block->nxt = &arr[i];
  256. prev_block = &arr[i];
  257. emp--;
  258. arr[i].used = 1;
  259. //if (sz < 30) break;
  260. }
  261. else {
  262. break;
  263. }
  264. }
  265. }
  266. }
  267. fclose(file);
  268. return first_adress;
  269. }
  270. else {
  271. fclose(file);
  272. cout << "No Space" << endl;
  273. return NULL;
  274. }
  275. }
  276. void write(DataCluster* start, char* path) {
  277. FILE* file = fopen(path, "wb+");
  278. if (file == NULL) {
  279. cout << "Error opening the file" << endl;
  280. return;
  281. }
  282. DataCluster* temp = start;
  283. while (start != NULL) {
  284. fwrite(start->data, 1, sizeof(start->data), file);
  285. start = start->nxt;
  286. }
  287. fclose(file);
  288. }
  289. char* get_name(string name) {
  290. int ind = 0;
  291. for (int i = name.size() - 1; i >= 0; i--) {
  292. if (name[i] == '\\') {
  293. ind = i;
  294. break;
  295. }
  296. }
  297. string ret = name.substr(ind + 1, (name.size() - ind + 1));
  298. char * r = (char*)malloc(300 * sizeof(char));
  299. strcpy(r, ret.c_str());
  300. return r;
  301. }
  302. void test_copy_helper(char* name) {
  303. for (auto &entry : std::experimental::filesystem::directory_iterator(name)) {
  304. string dir = entry.path().string();
  305. struct stat s;
  306. char* str = (char*)malloc(300 * sizeof(char));
  307. strcpy(str, dir.c_str());
  308. if (stat(str, &s) == 0) { //directory
  309. if (s.st_mode & S_IFDIR) {
  310. //cout << "folder" << endl;
  311. char* n = get_name(dir);
  312. creat_folder(n);
  313. move_to(n);
  314. test_copy_helper(str);
  315. move_back();
  316. }
  317. else if (s.st_mode & S_IFREG) { //file
  318. DirectoryEntrey *t = new DirectoryEntrey;
  319. DataCluster* temp = read(str, t->size);
  320. if (temp == NULL) {
  321. delete t;
  322. return;
  323. }
  324. t->starting_cluster = temp; strcpy(t->name, get_name(str));
  325. t->next = NULL;
  326. cur->directory_entres.push_back(*t);
  327. }
  328. }
  329. else {
  330. cout << "Error" << endl;
  331. }
  332. }
  333. }
  334.  
  335. void internal_copy(char* path) {
  336. if (!is_path(path)) {
  337. if (is_folder(path)) {
  338. folder_name = path;
  339. folder_hold = 1; file_hold = 0;
  340. bool ok = 0;
  341. for (int i = 0; i < cur->directory_entres.size(); i++) {
  342. if (strcmp(cur->directory_entres[i].name, path) == 0) {
  343. source_folder = new DirectoryCluster(*cur->directory_entres[i].next);
  344. ok = 1;
  345. break;
  346. }
  347. }
  348. if (!ok) {
  349. cout << " Direcotry NotFound" << endl;
  350. }
  351. return;
  352. }
  353. else {
  354. file_hold = 1; folder_hold = 0;
  355. bool ok = 0;
  356. for (int i = 0; i < cur->directory_entres.size(); i++) {
  357. if (strcmp(cur->directory_entres[i].name, path) == 0) {
  358. temp_holding_file = new DirectoryEntrey(cur->directory_entres[i]);
  359. ok = 1;
  360. break;
  361. }
  362. }
  363. if (!ok) {
  364. cout << "File not found" << endl;
  365. }
  366. return;
  367. }
  368. }
  369. string t = path;
  370. DirectoryCluster*temp = root;
  371. DirectoryCluster*previous = root;
  372. vector<string>road = Text::split_text(t);
  373. int j = 0;
  374. for (int i = 1; i < road.size(); i++) {
  375. bool ok = 0;
  376. for (j = 0; j < temp->directory_entres.size(); j++) {
  377. //cout << temp->directory_entres[j].name << endl;
  378. if (temp->directory_entres[j].name == road[i]) {
  379. previous = temp;
  380. temp = temp->directory_entres[j].next;
  381. ok = 1;
  382. break;
  383. }
  384. }
  385. if (!ok) {
  386. cout << "Wrong path" << endl;
  387. return;
  388. }
  389. }
  390. if (is_folder(road[road.size() - 1], temp)) { //folder
  391. source_folder = new DirectoryCluster(*temp); folder_name = get_name(path); //if temp changes source_folder changes too
  392. folder_hold = 1; file_hold = 0;
  393. }
  394. else {
  395. file_hold = 1; folder_hold = 0;
  396. temp_holding_file = new DirectoryEntrey(previous->directory_entres[j]);
  397. }
  398. }
  399.  
  400. void copy(char* path) {
  401. if (get_file_system(path) == "Root" || !is_path(path)) {
  402. internal_copy(path);
  403. return;
  404. }
  405. struct stat s;
  406. if (stat(path, &s) == 0) {
  407. if (s.st_mode & S_IFDIR) { //directory
  408. char* n = get_name(path);
  409. creat_folder(n);
  410. move_to(n);
  411. test_copy_helper(path);
  412. move_back();
  413. }
  414. else if (s.st_mode & S_IFREG) { //file
  415. DirectoryEntrey* t = new DirectoryEntrey;
  416. DataCluster* temp = read(path, t->size);
  417. if (temp == NULL) {
  418. return;
  419. }
  420. t->starting_cluster = temp;
  421. strcpy(t->name, get_name(path));
  422. t->next = NULL;
  423. cur->directory_entres.push_back(*t); //cased by null value (solved)
  424. }
  425. }
  426. else {
  427. cout << "Error" << endl;
  428. }
  429. }
  430. void past_helper(string path) {
  431. //cout << "done" << endl;
  432. //std::experimental::filesystem::create_directory("D:\\New folder (3)\\folder2");
  433. for (int i = 0; i < cur->directory_entres.size(); i++) {
  434. string temp = path;
  435. path += "\\"; path += cur->directory_entres[i].name;
  436. if (cur->directory_entres[i].starting_cluster == NULL) { //direcotry
  437. std::experimental::filesystem::create_directory(path);
  438. move_to(cur->directory_entres[i].name);
  439. past_helper(path);
  440. move_back();
  441. }
  442. else { //file
  443. char* str = (char*)malloc(300 * sizeof(char));
  444. strcpy(str, path.c_str());
  445. write(cur->directory_entres[i].starting_cluster, str);
  446. }
  447. path = temp;
  448. }
  449. }
  450. void internal_past_helper() {
  451. //DirectoryCluster* it = new DirectoryCluster(*source_folder);
  452. for (int i = 0; i < source_folder->directory_entres.size(); i++) {
  453. if (source_folder->directory_entres[i].starting_cluster == NULL) { //folder
  454. creat_folder(source_folder->directory_entres[i].name, distination_folder);
  455. move_to_loc(source_folder->directory_entres[i].name, distination_folder);
  456. move_to_loc(source_folder->directory_entres[i].name, source_folder);
  457. internal_past_helper();
  458. move_back(source_folder);
  459. move_back(distination_folder);
  460. }
  461. else { //file
  462. DirectoryEntrey* t = new DirectoryEntrey(source_folder->directory_entres[i]); //problem in this block of code
  463. t->starting_cluster = internal_read(t->starting_cluster, t->size);
  464. if (t->starting_cluster == NULL) {
  465. return;
  466. }
  467. t->next = NULL;
  468. distination_folder->directory_entres.push_back(*t);
  469. }
  470. }
  471. }
  472. void internal_past(char* path) {
  473. bool single_file_flag = 0;
  474. if (!is_path(path) || strlen(path) == 0) {
  475. single_file_flag = 1;
  476. }
  477. if (!single_file_flag) {
  478. vector<string>road = Text::split_text(path);
  479. DirectoryCluster* temp = root;
  480. for (int i = 1; i < road.size(); i++) {
  481. bool ok = 0;
  482. for (int j = 0; j < temp->directory_entres.size(); j++) {
  483. if (temp->directory_entres[j].name == road[i]) {
  484. ok = 1;
  485. temp = temp->directory_entres[j].next;
  486. break;
  487. }
  488. }
  489. if (!ok) {
  490. cout << "Wrong path" << endl;
  491. return;
  492. }
  493. }
  494. distination_folder = new DirectoryCluster( *temp );
  495. }
  496. else {
  497. distination_folder = new DirectoryCluster(*cur);
  498. }
  499. if (folder_hold) {
  500. if (source_folder == NULL || distination_folder == NULL) {
  501. cout << "No source or No distination , try again" << endl;
  502. return;
  503. }
  504. }
  505. if (file_hold) {
  506. if (temp_holding_file == NULL || distination_folder == NULL) {
  507. cout << "Nothing to past" << endl;
  508. return;
  509. }
  510. }
  511. if (folder_hold) {
  512. //cout << distination_folder << endl;
  513. char* str = (char*)malloc(300 * sizeof(char));
  514. strcpy(str, folder_name.c_str());
  515. creat_folder(str, distination_folder);
  516. move_to_loc(str, distination_folder);
  517. for (int i = 0; i < source_folder->directory_entres.size(); i++) {
  518. if (source_folder->directory_entres[i].starting_cluster == NULL) { //folder
  519. creat_folder(source_folder->directory_entres[i].name, distination_folder);
  520. move_to_loc(source_folder->directory_entres[i].name, distination_folder);
  521. move_to_loc(source_folder->directory_entres[i].name, source_folder);
  522. internal_past_helper();
  523. move_back(source_folder);
  524. move_back(distination_folder);
  525. }
  526. else { //file
  527. DirectoryEntrey* t = new DirectoryEntrey(source_folder->directory_entres[i]); //problem in this block of code
  528. t->starting_cluster = internal_read(t->starting_cluster, t->size);
  529. if (t->starting_cluster == NULL) {
  530. return;
  531. }
  532. t->next = NULL;
  533. distination_folder->directory_entres.push_back(*t);
  534. }
  535. }
  536. link(cur, distination_folder, str);
  537. }
  538. else {
  539. DirectoryEntrey* t;
  540. t = new DirectoryEntrey(*temp_holding_file);
  541. t->starting_cluster = internal_read(temp_holding_file->starting_cluster, t->size);
  542. distination_folder->directory_entres.push_back(*t);
  543. }
  544. //cur = temporary_memory;
  545. if (cut_flag) {
  546. cut_flag = 0;
  547. if (folder_hold) {
  548. source_folder = source_folder->prev;
  549. char* str = (char*)malloc(300 * sizeof(char));
  550. strcpy(str, folder_name.c_str());
  551. for (int i = 0; i < source_folder->directory_entres.size(); i++) {
  552. cout << source_folder->directory_entres[i].name << endl;
  553. system("PAUSE");
  554. if (strcmp(str, source_folder->directory_entres[i].name) == 0) {
  555. del(&source_folder->directory_entres[i], source_folder, i);
  556. break;
  557. }
  558. }
  559. source_folder = NULL;
  560. }
  561. else {
  562. for (int i = 0; i < source_folder->directory_entres.size(); i++) {
  563. if (strcmp(temp_holding_file->name, source_folder->directory_entres[i].name) == 0) {
  564. del(&source_folder->directory_entres[i], source_folder, i);
  565. break;
  566. }
  567. }
  568. temp_holding_file = NULL;
  569. source_folder = NULL;
  570. }
  571. }
  572. }
  573.  
  574. void test() {
  575. for (int i = 0; i < source_folder->directory_entres.size(); i++) {
  576. cout << source_folder->directory_entres[i].name << endl;
  577. if (source_folder->directory_entres[i].starting_cluster == NULL) {
  578. source_folder = source_folder->directory_entres[i].next;
  579. test();
  580. source_folder = source_folder->prev;
  581. }
  582. }
  583. }
  584.  
  585. void past(string path) {
  586. char* str = (char*)malloc(300 * sizeof(char));
  587. strcpy(str, path.c_str());
  588. if (get_file_system(str) == "Root") {
  589. internal_past(str);
  590. return;
  591. }
  592. else {
  593. past_helper(path);
  594. cout << "1" << endl;
  595. }
  596. }
  597. void del_helper(DirectoryCluster* d) {
  598. for (int i = 0; i < d->directory_entres.size(); i++) {
  599. //cout << d->directory_entres[i].name << endl;
  600. if (d->directory_entres[i].starting_cluster != NULL) { //file
  601. DataCluster* temp = d->directory_entres[i].starting_cluster;
  602. while (temp != NULL && temp->used == 1) {
  603. emp++;
  604. temp->used = 0;
  605. temp = temp->nxt;
  606. }
  607. }
  608. else { //directory
  609. move_to_loc(d->directory_entres[i].name, d);
  610. del_helper(d);
  611. move_back(d);
  612. //d->directory_entres[i].next = NULL;
  613. }
  614. }
  615. d = NULL;
  616. }
  617. void del(DirectoryEntrey* d, DirectoryCluster* cur_dir, int loc) {
  618. DataCluster* temp = d->starting_cluster;
  619. if (temp == NULL) { //folder ==> iterate over all the folders and files inside
  620. del_helper(cur_dir->directory_entres[loc].next);
  621. }
  622. else {
  623. while (temp != NULL && temp->used == 1) {
  624. emp++;
  625. temp->used = 0;
  626. temp = temp->nxt;
  627. }
  628. }
  629. cur_dir->directory_entres.erase(cur_dir->directory_entres.begin() + loc);
  630. }
  631. void pastFto(char* name, char* path) {
  632. if (is_folder(name)) {
  633. DirectoryCluster* t = cur;
  634. bool ok = 0;
  635. for (int i = 0; i < cur->directory_entres.size(); i++) {
  636. if (strcmp(name, cur->directory_entres[i].name) == 0) {
  637. cur = cur->directory_entres[i].next;
  638. ok = 1;
  639. break;
  640. }
  641. }
  642. if (ok) {
  643. past(path);
  644. cur = t;
  645. }
  646. else {
  647. cout << " Not found" << endl;
  648. return;
  649. }
  650. }
  651. else {
  652. for (int i = 0; i < cur->directory_entres.size(); i++) {
  653. if (strcmp(cur->directory_entres[i].name, name) == 0) {
  654. string p = path;
  655. p += "\\";
  656. p += name;
  657. char* str = (char*)malloc(300 * sizeof(char));
  658. strcpy(str, p.c_str());
  659. write(cur->directory_entres[i].starting_cluster, str);
  660. return;
  661. }
  662. }
  663. }
  664. }
  665. void cut(DirectoryEntrey* d, DirectoryCluster* cur_dir, int loc) {
  666. cut_flag = 1;
  667. internal_copy(d->name);
  668. }
  669. DirectoryCluster* get_cur_location() {
  670. return cur;
  671. }
  672. unsigned long long get_EmptySpots() {
  673. return emp;
  674. }
  675. void show_size() {
  676. cout << emp << endl;
  677. cout << floor((emp * 30) / (1024 * 1024)) << "MB" << endl;
  678. }
  679. void init(unsigned long long k) {
  680. emp = ceil((k * 1024 * (unsigned long long)1024) / 30);
  681. all_size = emp;
  682. arr = new DataCluster[emp];
  683.  
  684. root = new DirectoryCluster;
  685. cur = root; // this is suppose to change the value of the cur pointer
  686. root->prev = NULL;
  687. }
  688.  
  689. };
  690. string prev(string str) {
  691. for (int i = str.size() - 1; i >= 0; i--) {
  692. if (str[i] == '\\')
  693. return str.substr(0, i);
  694. }
  695. return str;
  696. }
  697.  
  698. int main() {
  699. FileSystem F1;
  700. string str;
  701. char path[200];
  702. unsigned long long l;
  703. cout << "Size in MB:";
  704. cin >> l;
  705. F1.init(l);
  706. string cur = "Root:";
  707. while (true) {
  708. //cout << F1.get_EmptySpots() << endl;
  709. cout << cur << ">";
  710. cin >> str;
  711. if (str == "copy") {
  712. cin >> path;
  713. F1.copy(path);
  714. }
  715. else if (str == "past") {
  716. cin >> path;
  717. F1.past(path);
  718. }
  719. else if (str == "pastf") {
  720. F1.internal_past("");
  721. }
  722. else if (str == "list") {
  723. F1.print_dir();
  724. }
  725. else if (str == "mov") {
  726. cin >> path;
  727. if (F1.move_to(path) == 0) {
  728. cout << "Directory not found" << endl;
  729. }
  730. else {
  731. cur += "\\"; cur += path;
  732. }
  733. }
  734. else if (str == "back") {
  735. F1.move_back();
  736. cur = prev(cur);
  737. }
  738. else if (str == "del") {
  739. cin >> path;
  740. bool ok = 0;
  741. DirectoryCluster* temp = F1.get_cur_location();
  742. for (int i = 0; i < temp->directory_entres.size(); i++) {
  743. if (strcmp(path, temp->directory_entres[i].name) == 0) {
  744. cout << temp->directory_entres[i].name << endl;
  745. F1.del(&temp->directory_entres[i], temp, i);
  746. ok = 1;
  747. break;
  748. }
  749. }
  750. if (!ok)
  751. cout << "File not found" << endl;
  752. }
  753. else if (str == "cf") {
  754. cin >> path;
  755. F1.creat_folder(path);
  756. }
  757. else if (str == "pastFto") {
  758. char name[200];
  759. cin >> name >> path;
  760. F1.pastFto(name, path);
  761. }
  762. else if (str == "size") {
  763. F1.show_size();
  764. }
  765. else if (str == "cut") {
  766. cin >> path;
  767. bool ok = 0;
  768. DirectoryCluster* temp = F1.get_cur_location();
  769. for (int i = 0; i < temp->directory_entres.size(); i++) {
  770. if (strcmp(path, temp->directory_entres[i].name) == 0) {
  771. //cout << temp->directory_entres[i].name << endl;
  772. F1.cut(&temp->directory_entres[i], temp, i);
  773. ok = 1;
  774. break;
  775. }
  776. }
  777. if (!ok)
  778. cout << "File not found" << endl;
  779. }
  780. }
  781. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:10:22: fatal error: filesystem: No such file or directory
 #include <filesystem>
                      ^
compilation terminated.
stdout
Standard output is empty