Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <dirent.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <pwd.h>
  6. #include <fcntl.h> /* флажки чтения и записи */
  7. #include <sys/types.h> /* определения типов */
  8. #include <sys/stat.h> /* структура, возвращаемая stat */
  9. int main(int argc, char* argv[])
  10. {
  11. char fir_link, sec_link;
  12. int i = 1;
  13. int s_flag = 0;
  14. if (argc < 3){
  15. printf("ERROR!\n");
  16. return 0;
  17. }
  18. while(strcmp(argv[i], "-s") == 0){
  19. s_flag = 1;
  20. i++;
  21. }
  22. if(argv[i] == NULL){
  23. printf("ERROR!\n");
  24. return 0;
  25. }
  26. if(argv[i+1] == NULL){
  27. printf("ERROR!\n");
  28. return 0;
  29. }
  30. if(s_flag == 0){
  31. link(argv[i], argv[i + 1]);
  32. }
  33. else{
  34. symlink(argv[i], argv[i + 1]);
  35. }
  36.  
  37.  
  38. return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement