Advertisement
Guest User

Untitled

a guest
May 20th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.31 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define MAX 100
  6.  
  7. //structura pentru trie
  8. typedef struct Trie
  9. {
  10. struct Trie *children[123];
  11. int wordEnd;
  12. }TrieNode;
  13.  
  14.  
  15. //aceasta functie converteste o cale din relativa in absoluta
  16. char *convertToAbsolute(char currentFile[], char currentDirectory[])
  17. {
  18. int i;
  19. char a[MAX];
  20. strcpy(a, currentFile);
  21. while (1)
  22. {
  23. int check = 0;
  24. while (currentFile[0] == '.' && currentFile[1] != '.')
  25. {
  26. currentFile = currentFile + 2;
  27. check = 1;
  28. }
  29. while (currentFile[0] == '.' && currentFile[1] == '.')
  30. {
  31. if (strlen(currentDirectory) == 1)
  32. {
  33. fprintf(stderr, "%s: No such file or directory\n", a);
  34. return "/";
  35. }
  36. char *aux = strrchr(currentDirectory, '/');
  37. char auxDir[100];
  38. for (i = 0; i < (int)(strlen(currentDirectory) - strlen(aux)); i++)
  39. {
  40. auxDir[i] = currentDirectory[i];
  41. }
  42. auxDir[i] = '\0';
  43. currentFile = currentFile + 3;
  44. currentDirectory = auxDir;
  45. check = 1;
  46. }
  47. if (check == 0)
  48. {
  49. break;
  50. }
  51. }
  52. char *auxFile = malloc(MAX);
  53. if(auxFile == NULL)
  54. {
  55. exit(-1);
  56. }
  57. if (strlen(currentDirectory) != 1)
  58. {
  59. strcpy(auxFile, currentDirectory);
  60. strcat(auxFile, "/");
  61. }
  62. else
  63. {
  64. strcpy(auxFile, "/");
  65. }
  66. strcat(auxFile, currentFile);
  67. currentFile = auxFile;
  68. return currentFile;
  69. }
  70.  
  71. //aceasta functie creaza un nod pentru trie si ii initializeaza copiii cu NULL
  72. TrieNode* createNode()
  73. {
  74. TrieNode *pNode = NULL;
  75.  
  76. pNode = malloc(sizeof(TrieNode));
  77.  
  78. if (pNode != NULL)
  79. {
  80. int i;
  81. pNode->wordEnd = 0;
  82. for (i = 0; i < 123; i++)
  83. {
  84. pNode->children[i] = NULL;
  85. }
  86. }
  87. else
  88. {
  89. exit(-1);
  90. }
  91.  
  92. return pNode;
  93. }
  94.  
  95. //aceasta functie insereaza un cuvant in trie
  96. void insert(TrieNode *root, const char file[])
  97. {
  98. int level;
  99. int length = strlen(file);
  100. int index;
  101.  
  102. TrieNode *pCrawl = root;
  103.  
  104. for (level = 0; level < length; level++)
  105. {
  106. index = (int)(file[level]);
  107. if (pCrawl->children[index] == NULL)
  108. {
  109. pCrawl->children[index] = createNode();
  110. }
  111. pCrawl = pCrawl->children[index];
  112. }
  113. pCrawl->wordEnd = 1;
  114. }
  115.  
  116. /*aceasta functie cauta un cuvant in trie si daca il gaseste returneaza 1,
  117. altfel 0*/
  118. int search(TrieNode *root, const char file[])
  119. {
  120. int level;
  121. int length = strlen(file);
  122. int index;
  123. TrieNode *pCrawl = root;
  124.  
  125. for (level = 0; level < length; level++)
  126. {
  127. index = (int)(file[level]);
  128.  
  129. if (pCrawl->children[index] == NULL)
  130. {
  131. return 0;
  132. }
  133. pCrawl = pCrawl->children[index];
  134. }
  135. if (pCrawl != NULL && pCrawl->wordEnd == 1)
  136. {
  137. return 1;
  138. }
  139. return 0;
  140. }
  141.  
  142. /*aceasta functie cauta un cuvant in trie, iar daca il gaseste returneaza
  143. un pointer la nod*/
  144. TrieNode *find(TrieNode *root, const char file[])
  145. {
  146. int level;
  147. int length = strlen(file);
  148. int index;
  149. TrieNode *pCrawl = root;
  150.  
  151. for (level = 0; level < length; level++)
  152. {
  153. index = (int)(file[level]);
  154.  
  155. if (pCrawl->children[index] == NULL)
  156. {
  157. return NULL;
  158. }
  159. pCrawl = pCrawl->children[index];
  160. }
  161. if (pCrawl != NULL && pCrawl->wordEnd == 1)
  162. {
  163. return pCrawl;
  164. }
  165. return NULL;
  166. }
  167.  
  168. //printeaza toate cuvintele copii ale acestui nod care contin un singur /
  169. void ls(TrieNode* root, char str[], int level, int type)
  170. {
  171. if (root->wordEnd == 1)
  172. {
  173. str[level] = '\0';
  174. if (str[0] != '\0')
  175. {
  176. char *p;
  177. char aux[MAX];
  178. strcpy(aux, str);
  179. aux[strlen(aux) - 1] = '\0';
  180. p = strchr(aux, '/');
  181. if (p == NULL)
  182. {
  183. if (type == 0)
  184. {
  185. printf("%s ", aux);
  186. }
  187. else
  188. {
  189. printf("%s ", str);
  190. }
  191. }
  192. }
  193. }
  194. int i;
  195. for (i = 0; i < 123; i++)
  196. {
  197. if (root->children[i])
  198. {
  199. str[level] = i;
  200. ls(root->children[i], str, level + 1, type);
  201. }
  202. }
  203. }
  204.  
  205. //verifica daca un nod are copiii nuli
  206. int isEmpty(TrieNode* root)
  207. {
  208. for (int i = 0; i < 123; i++)
  209. {
  210. if (root->children[i] != NULL)
  211. {
  212. return 0;
  213. }
  214. }
  215. return 1;
  216. }
  217.  
  218. //sterge toti copiii unui nod
  219. TrieNode* rm(TrieNode* root, char* file, int depth)
  220. {
  221. if (root == NULL)
  222. {
  223. return NULL;
  224. }
  225.  
  226. if (depth == (int)strlen(file))
  227. {
  228. if (root->wordEnd == 1)
  229. {
  230. root->wordEnd = 0;
  231. }
  232. if (isEmpty(root))
  233. {
  234. free(root);
  235. root = NULL;
  236. }
  237. return root;
  238. }
  239. int index = (int)(file[depth]);
  240. root->children[index] = rm(root->children[index], file, depth + 1);
  241. if (isEmpty(root) && root->wordEnd == 0)
  242. {
  243. free(root);
  244. root = NULL;
  245. }
  246. return root;
  247. }
  248.  
  249. //aceasta este functia de baza care citeste comenzile si le executa
  250. void execute()
  251. {
  252. TrieNode *root = createNode();
  253. char *currentDirectory = malloc(MAX);
  254. strcpy(currentDirectory, "/");
  255. insert(root, "/");
  256. char a[MAX], b[MAX], *p, *p2;
  257. int z, n;
  258. insert(root, "/");
  259. //citim numarul de comenzi
  260. if(fgets(a, sizeof(a), stdin) == NULL)
  261. {
  262. exit(-1);
  263. }
  264. n = atoi(a);
  265. TrieNode *auxTrie = malloc(sizeof(TrieNode));
  266. for(z = 0; z < n; z ++)
  267. {
  268. if(fgets(a, sizeof(a), stdin) == NULL)
  269. {
  270. return;
  271. }
  272. strcpy(b, a);
  273. p = strtok(a, " \n");
  274. //testam
  275. if (strcmp(p, "pwd") == 0)
  276. {
  277. printf("%s\n", currentDirectory);
  278. p = strtok(NULL, " \n");
  279. }
  280. else if (strcmp(p, "mkdir") == 0)
  281. {
  282. int i = 0;
  283. while (p != NULL)
  284. {
  285. i++;
  286. p = strtok(NULL, " \n");
  287. if (p != NULL)
  288. {
  289. char path[MAX];
  290. strcpy(path, p);
  291. if (p[0] == '.')
  292. {
  293. p = convertToAbsolute(p, currentDirectory);
  294. }
  295. else if (p[0] == '/')
  296. {
  297. p = convertToAbsolute(p, "\0");
  298. p = p + 1;
  299. }
  300. else
  301. {
  302. strcpy(b, "./");
  303. strcat(b, p);
  304. p = b;
  305. p = convertToAbsolute(p, currentDirectory);
  306. }
  307. char *p4 = strrchr(p, '/');
  308. p = strcat(p, "/");
  309. char y[MAX];
  310. strcpy(y, p);
  311. char *p5 = p;
  312. p5[strlen(p) - strlen(p4) + 1] = '\0';
  313. if(search(root, p5) == 0)
  314. {
  315. fprintf(stderr, "%s: No such file or directory\n",
  316. path);
  317. }
  318. else
  319. {
  320. if(search(root, y) == 0)
  321. {
  322. insert(root, y);
  323. }
  324. else
  325. {
  326. fprintf(stderr, "%s: already exists\n", path);
  327. }
  328. }
  329. }
  330. }
  331. if (i < 2)
  332. {
  333. fprintf(stderr, "mkdir: missing operand\n");
  334. }
  335. }
  336. else if (strcmp(p, "touch") == 0)
  337. {
  338. int i = 0;
  339. while (p != NULL)
  340. {
  341. i++;
  342. p = strtok(NULL, " \n");
  343. if (p != NULL)
  344. {
  345. char path[MAX];
  346. strcpy(path, p);
  347. if (p[0] == '.')
  348. {
  349. p = convertToAbsolute(p, currentDirectory);
  350. }
  351. else if (p[0] == '/')
  352. {
  353. p = convertToAbsolute(p, "\0");
  354. p = p + 1;
  355. }
  356. else
  357. {
  358. strcpy(b, "./");
  359. strcat(b, p);
  360. p = b;
  361. p = convertToAbsolute(p, currentDirectory);
  362. }
  363. char *p4 = strrchr(p, '/');
  364. p = strcat(p, "*");
  365. char y[MAX];
  366. strcpy(y, p);
  367. char *p5 = p;
  368. p5[strlen(p) - strlen(p4) + 1] = '\0';
  369. if(search(root, p5) == 0)
  370. {
  371. fprintf(stderr, "%s: No such file or directory\n",
  372. path);
  373. }
  374. else
  375. {
  376. if(search(root, y) == 0)
  377. {
  378. insert(root, y);
  379. }
  380. else
  381. {
  382. fprintf(stderr, "%s: already exists\n", path);
  383. }
  384. }
  385. }
  386. }
  387. if (i < 2)
  388. {
  389. fprintf(stderr, "touch: missing operand\n");
  390. }
  391. }
  392. else if (strcmp(p, "ls") == 0)
  393. {
  394. char y[MAX];
  395. strcpy(y, b);
  396. y[strlen(y) - 1] = '\0';
  397. if (strlen(currentDirectory) != 1)
  398. {
  399. strcat(currentDirectory, "/");
  400. }
  401. p = strtok(NULL, " \n");
  402. if (p == NULL)
  403. {
  404. auxTrie = find(root, currentDirectory);
  405. ls(auxTrie, b, 0, 0);
  406. printf("\n");
  407. if(strlen(currentDirectory) != 1)
  408. {
  409. currentDirectory[strlen(currentDirectory) - 1] = '\0';
  410. }
  411. continue;
  412. }
  413. else if (strcmp(p, "-F") == 0)
  414. {
  415. p = strtok(NULL, " \n");
  416. if (p == NULL)
  417. {
  418. auxTrie = find(root, currentDirectory);
  419. ls(auxTrie, b, 0, 1);
  420. printf("\n");
  421. }
  422. else
  423. {
  424. char path[MAX];
  425. strcpy(path, p);
  426. if(strlen(p) <= 2 && p[0] == '.')
  427. {
  428. currentDirectory[strlen(currentDirectory) - 1]
  429. = '\0';
  430. p = convertToAbsolute(p, currentDirectory);
  431. if(strlen(p) > 1)
  432. {
  433. while(p[strlen(p) - 1] == '/')
  434. {
  435. p[strlen(p) - 1] = '\0';
  436. }
  437. }
  438. strcat(currentDirectory, "/");
  439. }
  440. else
  441. {
  442. strcpy(b, "./");
  443. strcat(b, p);
  444. p = b;
  445. p = convertToAbsolute(p, currentDirectory);
  446. }
  447. p = strcat(p, "/");
  448. char aux[MAX];
  449. strcpy(aux, p);
  450. auxTrie = find(root, p);
  451. p2 = strtok(NULL, " \n");
  452. if (p2 != NULL)
  453. {
  454. fprintf(stderr, "%s: too many arguments\n", y);
  455. if(strlen(currentDirectory) != 1)
  456. {
  457. currentDirectory[strlen(currentDirectory) - 1]
  458. = '\0';
  459. }
  460. continue;
  461. }
  462. if (auxTrie == NULL)
  463. {
  464. fprintf(stderr, "%s: No such file or directory\n",
  465. path);
  466. if(strlen(currentDirectory) != 1)
  467. {
  468. currentDirectory[strlen(currentDirectory) - 1]
  469. = '\0';
  470. }
  471. continue;
  472. }
  473. else
  474. {
  475. p2 = strtok(NULL, " \n");
  476. if (p2 != NULL)
  477. {
  478. fprintf(stderr, "%s: too many arguments\n", y);
  479. if(strlen(currentDirectory) != 1)
  480. {
  481. currentDirectory[strlen(currentDirectory)
  482. - 1] = '\0';
  483. }
  484. continue;
  485. }
  486. ls(auxTrie, b, 0, 1);
  487. printf("\n");
  488. }
  489. }
  490. }
  491. else
  492. {
  493. char path[MAX];
  494. strcpy(path, p);
  495. if(strlen(p) < 3 && p[0] == '.')
  496. {
  497. currentDirectory[strlen(currentDirectory) - 1] = '\0';
  498. p = convertToAbsolute(p, currentDirectory);
  499. if(strlen(p) > 1)
  500. {
  501. p[strlen(p) - 1] = '\0';
  502. }
  503. strcat(currentDirectory, "/");
  504. }
  505. else if (p[0] != '/')
  506. {
  507. strcpy(b, "./");
  508. strcat(b, p);
  509. p = b;
  510. p = convertToAbsolute(p, currentDirectory);
  511. }
  512. if (strlen(p) != 1)
  513. {
  514. p = strcat(p, "/");
  515. }
  516. auxTrie = find(root, p);
  517. if (auxTrie == NULL)
  518. {
  519. fprintf(stderr, "%s: No such file or directory\n",
  520. path);
  521. if(strlen(currentDirectory) != 1)
  522. {
  523. currentDirectory[strlen(currentDirectory) - 1]
  524. = '\0';
  525. }
  526. continue;
  527. }
  528. else
  529. {
  530. p2 = strtok(NULL, " \n");
  531. if (p2 != NULL)
  532. {
  533. fprintf(stderr, "%s: too many arguments\n", y);
  534. if(strlen(currentDirectory) != 1)
  535. {
  536. currentDirectory[strlen(currentDirectory) - 1]
  537. = '\0';
  538. }
  539. break;
  540. }
  541. ls(auxTrie, b, 0, 0);
  542. printf("\n");
  543. }
  544. }
  545. if(strlen(currentDirectory) != 1)
  546. {
  547. currentDirectory[strlen(currentDirectory) - 1] = '\0';
  548. }
  549. }
  550. else if (strcmp(p, "cp") == 0)
  551. {
  552. p = strtok(NULL, " \n");
  553. p2 = strrchr(b, ' ');
  554. if (p2 == NULL)
  555. {
  556. fprintf(stderr, "cp: missing operand\n");
  557. continue;
  558. }
  559. char path[MAX];
  560. p2 = p2 + 1;
  561. p2[strlen(p2) - 1] = '\0';
  562. strcpy(path, p2);
  563. if (strcmp(p, p2) == 0)
  564. {
  565. fprintf(stderr, "cp: missing operand\n");
  566. continue;
  567. }
  568. char c[MAX];
  569. strcpy(c, p2);
  570. if (p2[0] == '.')
  571. {
  572. p2 = convertToAbsolute(p2, currentDirectory);
  573. }
  574. else if (p2[0] != '/' && p2[0] != '.')
  575. {
  576. strcpy(b, "./");
  577. strcat(b, p2);
  578. p2 = b;
  579. p2 = convertToAbsolute(p2, currentDirectory);
  580. }
  581. p2 = strcat(p2, "/");
  582. if (search(root, p2) == 0)
  583. {
  584. fprintf(stderr, "%s: No such file or directory\n", path);
  585. continue;
  586. }
  587. int i = 0;
  588. while (strcmp(p, c) != 0)
  589. {
  590. char path[MAX];
  591. strcpy(path, p);
  592. i++;
  593. if (p[0] == '.')
  594. {
  595. p = convertToAbsolute(p, currentDirectory);
  596. }
  597. else if (p[0] != '/' && p[0] != '.')
  598. {
  599. strcpy(b, "./");
  600. strcat(b, p);
  601. p = b;
  602. p = convertToAbsolute(p, currentDirectory);
  603. }
  604. if (strlen(p) != 1)
  605. {
  606. p = strcat(p, "*");
  607. }
  608. if (search(root, p) == 0)
  609. {
  610. fprintf(stderr, "%s: No such file or directory\n",
  611. path);
  612. }
  613. else
  614. {
  615. p = p + 1;
  616. strcat(p2, p);
  617. insert(root, p2);
  618. }
  619. p = strtok(NULL, " \n");
  620. }
  621. if (i < 1)
  622. {
  623. fprintf(stderr, "cp: missing operand\n");
  624. }
  625. }
  626. else if (strcmp(p, "cd") == 0)
  627. {
  628. p = strtok(NULL, " \n");
  629. if (p == NULL)
  630. {
  631. strcpy(currentDirectory,"/");
  632. continue;
  633. }
  634. else
  635. {
  636. char path[MAX];
  637. strcpy(path, p);
  638. if(p[0] == '.' && strlen(p) == 2)
  639. {
  640. p = convertToAbsolute(p, currentDirectory);
  641. if(strlen(p) > 1)
  642. {
  643. p[strlen(p) - 1] = '\0';
  644. }
  645. }
  646. else if (p[0] == '.')
  647. {
  648. p = convertToAbsolute(p, currentDirectory);
  649. }
  650. else if (p[0] != '/' && p[0] != '.')
  651. {
  652. strcpy(b, "./");
  653. strcat(b, p);
  654. p = b;
  655. p = convertToAbsolute(p, currentDirectory);
  656. }
  657. if (strlen(p) != 1)
  658. {
  659. int j = strlen(p) + 1;
  660. p[strlen(p)] = '/';
  661. p[j] = '\0';
  662. }
  663. char y[MAX];
  664. strcpy(y, p);
  665. y[strlen(y) - 1] = '*';
  666. if (search(root, y) == 1)
  667. {
  668. fprintf(stderr, "%s: Not a directory\n", path);
  669. }
  670. else if (search(root, p) == 0)
  671. {
  672. fprintf(stderr, "%s: No such file or directory\n",
  673. path);
  674. }
  675. else
  676. {
  677. if (strlen(p) != 1)
  678. {
  679. p[strlen(p) - 1] = '\0';
  680. }
  681. if(strcmp(currentDirectory, p) != 0)
  682. {
  683. strcpy(currentDirectory, p);
  684. }
  685. }
  686.  
  687. }
  688. }
  689. else if (strcmp(p, "rmdir") == 0)
  690. {
  691. p = strtok(NULL, " \n");
  692. if (p == NULL)
  693. {
  694. fprintf(stderr, "rmdir: missing operand\n");
  695. continue;
  696. }
  697. while (p != NULL)
  698. {
  699. char path[MAX];
  700. strcpy(path, p);
  701. if (p[0] == '.')
  702. {
  703. p = convertToAbsolute(p, currentDirectory);
  704. }
  705. else if (p[0] != '/' && p[0] != '.')
  706. {
  707. strcpy(b, "./");
  708. strcat(b, p);
  709. p = b;
  710. p = convertToAbsolute(p, currentDirectory);
  711. }
  712. if (strlen(p) != 1)
  713. {
  714. p = strcat(p, "/");
  715. }
  716. if (search(root, p) == 0)
  717. {
  718. fprintf(stderr, "%s: No such file or directory\n",
  719. path);
  720. }
  721. else
  722. {
  723. if (isEmpty(find(root, p)) == 1)
  724. {
  725. root = rm(root, p, 0);
  726. }
  727. else
  728. {
  729. fprintf(stderr, "%s: Directory not empty\n",
  730. path);
  731. }
  732. }
  733. p = strtok(NULL, " \n");
  734. }
  735. }
  736. else if (strcmp(p, "rm") == 0)
  737. {
  738. p = strtok(NULL, " \n");
  739. if (p == NULL)
  740. {
  741. fprintf(stderr, "rm: missing operand\n");
  742. continue;
  743. }
  744. while (p != NULL)
  745. {
  746. char path[MAX];
  747. strcpy(path, p);
  748. if (p[0] == '.')
  749. {
  750. p = convertToAbsolute(p, currentDirectory);
  751. }
  752. else if (p[0] != '/' && p[0] != '.')
  753. {
  754. strcpy(b, "./");
  755. strcat(b, p);
  756. p = b;
  757. p = convertToAbsolute(p, currentDirectory);
  758. }
  759. if (strlen(p) != 1)
  760. {
  761. p = strcat(p, "/");
  762. }
  763. char y[MAX];
  764. strcpy(y, p);
  765. y[strlen(y) - 1] = '*';
  766. if (search(root, p) == 1)
  767. {
  768. root = rm(root, p, 0);
  769. }
  770. else if (search(root, y) == 1)
  771. {
  772. root = rm(root, y, 0);
  773. }
  774. else
  775. {
  776. fprintf(stderr, "%s: No such file or directory\n",
  777. path);
  778. }
  779. p = strtok(NULL, " \n");
  780. }
  781. }
  782. else if (strcmp(p, "mv") == 0)
  783. {
  784. p = strtok(NULL, " \n");
  785. p2 = strrchr(b, ' ');
  786. if (p2 == NULL)
  787. {
  788. fprintf(stderr, "%s: missing operand\n", b);
  789. continue;
  790. }
  791. p2 = p2 + 1;
  792. p2[strlen(p2) - 1] = '\0';
  793. char path[MAX], path2[MAX];
  794. strcpy(path, p);
  795. strcpy(path2, p2);
  796. if (strcmp(p, p2) == 0)
  797. {
  798. fprintf(stderr, "%s: missing operand\n", b);
  799. continue;
  800. }
  801. char c[MAX];
  802. strcpy(c, p2);
  803. if (p2[0] == '.')
  804. {
  805. p2 = convertToAbsolute(p2, currentDirectory);
  806. }
  807. else if (p2[0] != '/' && p2[0] != '.')
  808. {
  809. strcpy(b, "./");
  810. strcat(b, p2);
  811. p2 = b;
  812. p2 = convertToAbsolute(p2, currentDirectory);
  813. }
  814. p2 = strcat(p2, "/");
  815. char y[MAX];
  816. strcpy(y, p2);
  817. y[strlen(y) - 1] = '*';
  818. if (search(root, y) == 1)
  819. {
  820. fprintf(stderr, "%s: Not a directory\n", path2);
  821. continue;
  822. }
  823. int i = 0;
  824. while (strcmp(p, c) != 0)
  825. {
  826. char path[MAX];
  827. strcpy(path, p);
  828. i++;
  829. if (p[0] == '.')
  830. {
  831. p = convertToAbsolute(p, currentDirectory);
  832. }
  833. else if (p[0] != '/' && p[0] != '.')
  834. {
  835. strcpy(b, "./");
  836. strcat(b, p);
  837. p = b;
  838. p = convertToAbsolute(p, currentDirectory);
  839. }
  840. if (strlen(p) != 1)
  841. {
  842. p = strcat(p, "*");
  843. }
  844. if (search(root, p) == 0)
  845. {
  846. fprintf(stderr, "%s: No such file or directory\n",
  847. path);
  848. break;
  849. }
  850. else if (search(root, p2) == 0)
  851. {
  852. fprintf(stderr, "%s: No such file or directory\n",
  853. path2);
  854. break;
  855. }
  856. else
  857. {
  858. root = rm(root, p, 0);
  859. p = p + 1;
  860. strcat(p2, p);
  861. insert(root, p2);
  862. }
  863. p = strtok(NULL, " \n");
  864. }
  865. if (i < 1)
  866. {
  867. fprintf(stderr, "mv: missing operand\n");
  868. }
  869. }
  870. else
  871. {
  872. fprintf(stderr, "%s: command not found\n", p);
  873. }
  874. }
  875. rm(root, "/", 0);
  876. free(currentDirectory);
  877. free(root);
  878. }
  879.  
  880. int main()
  881. {
  882. execute();
  883. return 0;
  884. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement