Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. char* a_new_abs_dir(int sockfd){
  2.     char* readerer;
  3.     char* output = malloc(strlen("type the new absolute directory: \0")+1);
  4.     output = strcpy(output, "type the new absolute directory: \0");
  5.     if(state == write_state){
  6.         if(write_on_roids(sockfd, output) == -1){
  7.             perror("OOPS! something went wrong: ");
  8.             free(output);
  9.             exit(EXIT_FAILURE);
  10.         }
  11.         state = read_state;
  12.         free(output);
  13.     }
  14.     if(state == read_state){
  15.         readerer = read_on_roids(sockfd);
  16.         state = write_state;
  17.     }
  18.  
  19.     output = malloc(strlen(readerer)+strlen(topDir)+1);
  20.     strcpy(output, topDir);
  21.     strcat(output, readerer);
  22.     if(chdir(output) == -1){
  23.         output = realloc(output, strlen(strerror(errno))+2);
  24.         strcpy(output,strerror(errno));
  25.         strcat(output, "\n\0");
  26.         return output;
  27.     }
  28.     strcpy(currentDir, output);
  29.     return output;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement