cleanup
This commit is contained in:
@@ -380,37 +380,3 @@ void dir_init(){
|
||||
current_linked_dir = list_beginning;
|
||||
|
||||
}
|
||||
|
||||
void recursive_delete(file current_file){
|
||||
/*
|
||||
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);
|
||||
if (current_file_count != 0) {
|
||||
file *current_dir = malloc(current_file_count * sizeof(file));
|
||||
memset(current_dir, '\0', current_file_count * sizeof(file));
|
||||
get_dir_content(current_file.file_name, ¤t_file_count, current_dir);
|
||||
if (chdir(current_file.file_name) != 0) {
|
||||
return;
|
||||
}
|
||||
unsigned long i;
|
||||
for (i = 0; i < current_file_count; i++) {
|
||||
recursive_delete(current_dir[i]);
|
||||
free(current_dir[i].file_name);
|
||||
}
|
||||
free(current_dir);
|
||||
if (chdir("..") != 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
remove(current_file.file_name);
|
||||
file_modifiers = file_modifiers_tmp;
|
||||
|
||||
} else {
|
||||
remove(current_file.file_name);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -10,4 +10,3 @@ char update_selected_file();
|
||||
void dir_set_selected_file_current(unsigned long selected_file_current);
|
||||
unsigned long dir_get_selected_file_current();
|
||||
void dir_init();
|
||||
void recursive_delete(file current_file);
|
||||
|
||||
+23
-36
@@ -41,10 +41,7 @@ yank yank_files = { 0 };
|
||||
printf("TODO: %s at %d in %s \n", __func__, __LINE__, __FILE__);\
|
||||
exit(1);
|
||||
|
||||
void FAIL(char *function, char *str){
|
||||
printf("ERROR in function %s: %s", function, str);
|
||||
}
|
||||
#define continue_if_empty_dir \
|
||||
#define skip_if_empty_dir \
|
||||
if (mid_dir.current_file == NULL) { \
|
||||
return; \
|
||||
}
|
||||
@@ -126,7 +123,6 @@ int read_string(WINDOW *win, int y, int x, char *str){
|
||||
|
||||
wmove(win, y, x);
|
||||
while(1) {
|
||||
/*ch = mvwgetch(win, y, x + pass);*/
|
||||
ch = wgetch(win);
|
||||
if (ch == '\n') {
|
||||
err = 0;
|
||||
@@ -170,7 +166,7 @@ void select_all(){
|
||||
}
|
||||
void move_down(unsigned long passes){
|
||||
|
||||
continue_if_empty_dir;
|
||||
skip_if_empty_dir;
|
||||
|
||||
mid_dir.current_file += passes;
|
||||
if (mid_dir.current_file > mid_dir.file_list + mid_dir.file_count - 1) {
|
||||
@@ -181,7 +177,7 @@ void move_down(unsigned long passes){
|
||||
}
|
||||
void move_up(unsigned long passes){
|
||||
|
||||
continue_if_empty_dir;
|
||||
skip_if_empty_dir;
|
||||
|
||||
mid_dir.current_file -= passes;
|
||||
if (mid_dir.current_file < mid_dir.file_list) {
|
||||
@@ -200,7 +196,7 @@ void move_left(unsigned long passes){
|
||||
}
|
||||
void move_right(){
|
||||
|
||||
continue_if_empty_dir
|
||||
skip_if_empty_dir
|
||||
|
||||
if (mid_dir.current_file->file_type & FILE_TYPE_DIR) {
|
||||
change_dir(mid_dir.current_file->file_name);
|
||||
@@ -340,7 +336,6 @@ void delete(unsigned long passes){
|
||||
|
||||
unsigned long i;
|
||||
unsigned long del_count = 0;
|
||||
file tmp;
|
||||
char *cmd;
|
||||
|
||||
for (i = 0; i < mid_dir.file_count; i++) {
|
||||
@@ -406,14 +401,6 @@ void enter_shell(unsigned long passes, int index){
|
||||
status |= (STATUS_RUN_BACKEND | STATUS_RELOAD_DIRECTORY);
|
||||
|
||||
}
|
||||
void not_implemented(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
|
||||
mvaddstr(terminal_height-1, 0, key_binding[index].comment);
|
||||
mvaddstr(terminal_height-1, strlen(key_binding[index].comment), "\t");
|
||||
mvaddstr(terminal_height-1, strlen(key_binding[index].comment) + strlen("\t"), "is not yet implemented");
|
||||
TODO;
|
||||
}
|
||||
void jump_to_dir(unsigned long passes, int index){
|
||||
(void)passes;
|
||||
|
||||
@@ -600,13 +587,14 @@ void search(){
|
||||
|
||||
unsigned int pass = 0;
|
||||
char ch;
|
||||
char err = 0;
|
||||
|
||||
wmove(win_b, 0, 1);
|
||||
while(1) {
|
||||
ch = wgetch(win_b);
|
||||
if (ch == '\n') {
|
||||
err = 0;
|
||||
if (ch == '\n' || ch == 27 /* esc key */) {
|
||||
/* unlike the other uses of a read string reimplementation,
|
||||
* here we do not differentiate between accepting and cancle.
|
||||
* this is intentional */
|
||||
break;
|
||||
} else if (ch == '\t') { /* tab */
|
||||
memcpy(search_buffer + pass, mid_dir.current_file->file_name, strlen(mid_dir.current_file->file_name));
|
||||
@@ -617,9 +605,6 @@ void search(){
|
||||
pass--;
|
||||
mvwdelch(win_b, 0, pass+1);
|
||||
}
|
||||
} else if (ch == 27) { /* esc key */
|
||||
err = 1;
|
||||
break;
|
||||
}
|
||||
if (ch) {
|
||||
mvwaddch(win_b, 0, pass+1, ch);
|
||||
@@ -627,7 +612,6 @@ void search(){
|
||||
pass++;
|
||||
|
||||
unsigned long index = (mid_dir.current_file - mid_dir.file_list);
|
||||
unsigned long x = getmaxx(win_b);
|
||||
for (; &mid_dir.file_list[index] < mid_dir.file_list + mid_dir.file_count; index++) {
|
||||
if (smartstrcasestr(mid_dir.file_list[index].file_name, search_buffer)) {
|
||||
mid_dir.current_file = &mid_dir.file_list[index];
|
||||
@@ -675,7 +659,13 @@ void search_previous(){
|
||||
status |= (STATUS_RUN_BACKEND);
|
||||
}
|
||||
void jmp_file_index(){
|
||||
echo();
|
||||
|
||||
|
||||
char ch;
|
||||
char err = 0;
|
||||
char number_buffer[INPUT_BUFFER_SIZE];
|
||||
char *num = number_buffer;
|
||||
|
||||
unsigned long i;
|
||||
for (i = 0; i < terminal_width -1; i++) {
|
||||
mvwaddch(win_b, 0, i, ' ');
|
||||
@@ -685,14 +675,8 @@ void jmp_file_index(){
|
||||
|
||||
curs_set(1);
|
||||
echo();
|
||||
|
||||
timeout(-1); /* negative numbers block until enter is pressed */
|
||||
|
||||
unsigned int pass = 0;
|
||||
char ch;
|
||||
char err = 0;
|
||||
char number_buffer[INPUT_BUFFER_SIZE];
|
||||
char *num = number_buffer;
|
||||
|
||||
wmove(win_b, 0, 1);
|
||||
while(1) {
|
||||
@@ -704,6 +688,7 @@ void jmp_file_index(){
|
||||
} else if (ch == '\n') {
|
||||
break;
|
||||
} else if (ch == 27) { /* esc key */
|
||||
err = 1;
|
||||
break;
|
||||
} else if (ch == 127) { /* backspace */
|
||||
num--;
|
||||
@@ -715,12 +700,14 @@ void jmp_file_index(){
|
||||
*num = 0;
|
||||
num = number_buffer;
|
||||
|
||||
unsigned long parsed_number = 0;
|
||||
while(*num) {
|
||||
parsed_number = (parsed_number * 10) + (*num - '0');
|
||||
num++;
|
||||
if (err == 0) {
|
||||
unsigned long parsed_number = 0;
|
||||
while(*num) {
|
||||
parsed_number = (parsed_number * 10) + (*num - '0');
|
||||
num++;
|
||||
}
|
||||
mid_dir.current_file = &mid_dir.file_list[parsed_number];
|
||||
}
|
||||
mid_dir.current_file = &mid_dir.file_list[parsed_number];
|
||||
|
||||
noecho();
|
||||
curs_set(0);
|
||||
|
||||
Reference in New Issue
Block a user