Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char* a_new_abs_dir(int sockfd){
- char* readerer;
- char* output = malloc(strlen("type the new absolute directory: \0")+1);
- output = strcpy(output, "type the new absolute directory: \0");
- if(state == write_state){
- if(write_on_roids(sockfd, output) == -1){
- perror("OOPS! something went wrong: ");
- free(output);
- exit(EXIT_FAILURE);
- }
- state = read_state;
- free(output);
- }
- if(state == read_state){
- readerer = read_on_roids(sockfd);
- state = write_state;
- }
- output = malloc(strlen(readerer)+strlen(topDir)+1);
- strcpy(output, topDir);
- strcat(output, readerer);
- if(chdir(output) == -1){
- output = realloc(output, strlen(strerror(errno))+2);
- strcpy(output,strerror(errno));
- strcat(output, "\n\0");
- return output;
- }
- strcpy(currentDir, output);
- return output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement