removal of unnecessary getcwd
This commit is contained in:
@@ -319,16 +319,15 @@ void dir_changed(){
|
||||
}
|
||||
void change_dir(char *new_path){
|
||||
|
||||
const char *old_path = global_path;
|
||||
current_linked_dir = list_beginning;
|
||||
while (current_linked_dir->next != NULL) {
|
||||
if(strcmp(current_linked_dir->path, old_path) == 0) {
|
||||
if(strcmp(current_linked_dir->path, global_path) == 0) {
|
||||
break;
|
||||
} else {
|
||||
current_linked_dir = current_linked_dir->next;
|
||||
}
|
||||
}
|
||||
if(strcmp(current_linked_dir->path, old_path) == 0) {
|
||||
if(strcmp(current_linked_dir->path, global_path) == 0) {
|
||||
current_linked_dir->index = mid_dir.current_file - mid_dir.file_list;
|
||||
}
|
||||
|
||||
@@ -338,21 +337,22 @@ void change_dir(char *new_path){
|
||||
* especially in like 2 years when i even forgot about this possibility */
|
||||
return;
|
||||
}
|
||||
char *new_path_real = getcwd(NULL, 0);
|
||||
free(global_path);
|
||||
global_path = getcwd(NULL, 0);
|
||||
|
||||
current_linked_dir = list_beginning;
|
||||
while (current_linked_dir->next != NULL) {
|
||||
if(strcmp(current_linked_dir->path, new_path_real) == 0) {
|
||||
if(strcmp(current_linked_dir->path, global_path) == 0) {
|
||||
break;
|
||||
} else {
|
||||
current_linked_dir = current_linked_dir->next;
|
||||
}
|
||||
}
|
||||
if(strcmp(current_linked_dir->path, new_path_real) != 0) {
|
||||
if(strcmp(current_linked_dir->path, global_path) != 0) {
|
||||
current_linked_dir->next = malloc(sizeof(linked_dir));
|
||||
current_linked_dir = current_linked_dir->next;
|
||||
current_linked_dir->path = malloc(strlen(new_path_real)+1);
|
||||
memcpy(current_linked_dir->path, new_path_real, strlen(new_path_real)+1);
|
||||
current_linked_dir->path = malloc(strlen(global_path)+1);
|
||||
memcpy(current_linked_dir->path, global_path, strlen(global_path)+1);
|
||||
current_linked_dir->next = NULL;
|
||||
current_linked_dir->index = 0;
|
||||
/*TODO(2026-05-25T22:49:30)
|
||||
@@ -360,8 +360,6 @@ void change_dir(char *new_path){
|
||||
}
|
||||
mid_dir.current_file = &mid_dir.file_list[current_linked_dir->index];
|
||||
|
||||
free(new_path_real);
|
||||
|
||||
}
|
||||
|
||||
void dir_init(){
|
||||
|
||||
Reference in New Issue
Block a user