mirror of
https://gittea.dev/nova/th.git
synced 2026-01-30 16:50:10 -05:00
multiple small changes
This commit is contained in:
19
dir.c
19
dir.c
@@ -83,11 +83,7 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
||||
dir_content[i].file_size = file->st_size;
|
||||
dir_content[i].permissions = file->st_mode;
|
||||
|
||||
if (S_ISDIR(file->st_mode)) {
|
||||
dir_content[i].file_type = FILE_TYPE_DIR;
|
||||
dir_content[i].color_pair = COLOR_DIR;
|
||||
dir_content[i].file_size = get_dir_size(full_path);
|
||||
} else if (S_ISLNK(file->st_mode)) {
|
||||
if (S_ISLNK(file->st_mode)) {
|
||||
stat(full_path, file);
|
||||
if (S_ISDIR(file->st_mode)) {
|
||||
dir_content[i].file_type = FILE_TYPE_DIR | FILE_TYPE_SYMLINK;
|
||||
@@ -97,6 +93,10 @@ void get_dir_content(char *path, unsigned long *dir_file_count, file *dir_conten
|
||||
dir_content[i].file_type = FILE_TYPE_REGULAR | FILE_TYPE_SYMLINK;
|
||||
dir_content[i].color_pair = COLOR_SYMLINK;
|
||||
}
|
||||
} else if (S_ISDIR(file->st_mode)) {
|
||||
dir_content[i].file_type = FILE_TYPE_DIR;
|
||||
dir_content[i].color_pair = COLOR_DIR;
|
||||
dir_content[i].file_size = get_dir_size(full_path);
|
||||
} else if (file->st_mode & S_IXUSR) {
|
||||
dir_content[i].file_type = FILE_TYPE_EXEC;
|
||||
dir_content[i].color_pair = COLOR_EXEC;
|
||||
@@ -327,9 +327,6 @@ void print_dir(WINDOW *win, char print_info, unsigned long *dir_file_count, file
|
||||
|
||||
char update_selected_file(){
|
||||
char ret = -1; /* -1 on empty or inaccessible file, 0 on unchanged file, 1 on changed file */
|
||||
if (mid_content->file_name[0] == '\0') { /* only happens if the current path is either empty or inaccessible */
|
||||
return ret;
|
||||
}
|
||||
if (selected_file_current >= mid_file_count) {
|
||||
selected_file_current = mid_file_count-1;
|
||||
}
|
||||
@@ -344,7 +341,7 @@ char update_selected_file(){
|
||||
return ret;
|
||||
}
|
||||
void dir_set_selected_file_current(unsigned long selected_file_current){
|
||||
if (mid_content->file_name[0] != '\0') {
|
||||
if (mid_content->file_name) {
|
||||
current_dir->selected_file_current = selected_file_current;
|
||||
}
|
||||
}
|
||||
@@ -384,7 +381,9 @@ void dir_init(){
|
||||
}
|
||||
|
||||
void recursive_delete(file current_file){
|
||||
if (current_file.file_type & FILE_TYPE_DIR) {
|
||||
if (S_ISLNK(current_file.permissions)) {
|
||||
remove(current_file.file_name);
|
||||
} else if (current_file.file_type & FILE_TYPE_DIR ) {
|
||||
unsigned int file_modifiers_tmp = file_modifiers;
|
||||
file_modifiers |= FILE_MODIFIERS_HIDDEN_FILES;
|
||||
unsigned long current_file_count = get_dir_size(current_file.file_name);
|
||||
|
||||
Reference in New Issue
Block a user