improvenment of path handling
This commit is contained in:
14
threading.c
14
threading.c
@ -58,6 +58,7 @@ void *thread_lft(void *data){
|
||||
|
||||
free(lft_content);
|
||||
|
||||
|
||||
char *path;
|
||||
if((path=getcwd(NULL, 0)) == NULL) {
|
||||
lft_content = malloc(sizeof(file));
|
||||
@ -66,18 +67,13 @@ void *thread_lft(void *data){
|
||||
lft_file_count = 1;
|
||||
} else {
|
||||
|
||||
char *parent ;
|
||||
if((parent = malloc(strlen(path)+strlen("/..")+1)) != NULL){
|
||||
parent[0] = '\0'; /* ensures empty string */
|
||||
strcat(parent, path);
|
||||
strcat(parent, "/..");
|
||||
}
|
||||
path[strrchr(path, '/')-path] = '\0';
|
||||
path[0] = '/';
|
||||
|
||||
lft_file_count = (unsigned long)get_dir_size(parent);
|
||||
lft_file_count = (unsigned long)get_dir_size(path);
|
||||
lft_content = malloc(lft_file_count * sizeof(file));
|
||||
memset(lft_content, ' ', lft_file_count * sizeof(file));
|
||||
get_dir_content(parent, &lft_file_count, lft_content);
|
||||
free(parent);
|
||||
get_dir_content(path, &lft_file_count, lft_content);
|
||||
|
||||
}
|
||||
free(path);
|
||||
|
Reference in New Issue
Block a user