xaizek / vifm (License: GPLv2+) (since 2018-12-07)
Vifm is a file manager with curses interface, which provides Vi[m]-like environment for managing objects within file systems, extended with some useful ideas from mutt.
Commit e52be8641a81041a4f207074970693612e54cab4

Don't reload view on directory changing error.
Author: xaizek
Author date (UTC): 2011-05-20 16:13
Committer name: xaizek
Committer date (UTC): 2011-05-20 16:13
Parent(s): c70e73b9fdb325a94e3c26df8f3a69a257cb3ef7
Signing key:
Tree: c2399ae9b1eaf691158c6e0259ce65fc568178f9
File Lines added Lines deleted
src/filelist.c 12 23
src/filelist.h 1 2
src/fileops.c 1 2
src/sort.c 10 0
File src/filelist.c changed (mode: 100644) (index 926752e1e..ce11119d8)
... ... leave_invalid_dir(FileView *view, char *path)
911 911 * or an absolute path - /usr/local/share * or an absolute path - /usr/local/share
912 912 * The *directory passed to change_directory() cannot be modified. * The *directory passed to change_directory() cannot be modified.
913 913 * Symlink directories require an absolute path * Symlink directories require an absolute path
914 *
915 * Returns 0 if there was no errors.
914 916 */ */
915 void
917 int
916 918 change_directory(FileView *view, const char *directory) change_directory(FileView *view, const char *directory)
917 919 { {
918 920 DIR *dir; DIR *dir;
 
... ... change_directory(FileView *view, const char *directory)
970 972 werase(status_bar); werase(status_bar);
971 973 show_error_msg("FUSE UMOUNT ERROR", runner->source_file_name); show_error_msg("FUSE UMOUNT ERROR", runner->source_file_name);
972 974 chdir(view->curr_dir); chdir(view->curr_dir);
973 return;
975 return -1;
974 976 } }
975 977 /*remove the DIR we created for the mount*/ /*remove the DIR we created for the mount*/
976 978 if(!access(runner->mount_point, F_OK)) if(!access(runner->mount_point, F_OK))
 
... ... change_directory(FileView *view, const char *directory)
994 996 found = find_file_pos_in_list(view, filen); found = find_file_pos_in_list(view, filen);
995 997 moveto_list_pos(view, found); moveto_list_pos(view, found);
996 998 free(runner); free(runner);
997 return;
999 return 0;
998 1000 } }
999 1001 } }
1000 1002
 
... ... change_directory(FileView *view, const char *directory)
1087 1089 leave_invalid_dir(view, dir_dup); leave_invalid_dir(view, dir_dup);
1088 1090 change_directory(view, dir_dup); change_directory(view, dir_dup);
1089 1091 clean_selected_files(view); clean_selected_files(view);
1090 return;
1092 return -1;
1091 1093 } }
1092 1094
1093 1095 if(access(dir_dup, R_OK) != 0) if(access(dir_dup, R_OK) != 0)
 
... ... change_directory(FileView *view, const char *directory)
1096 1098 "You do not have read access on that directory"); "You do not have read access on that directory");
1097 1099
1098 1100 clean_selected_files(view); clean_selected_files(view);
1099 return;
1101 return -1;
1100 1102 } }
1101 1103
1102 1104 if(access(dir_dup, X_OK) != 0) if(access(dir_dup, X_OK) != 0)
 
... ... change_directory(FileView *view, const char *directory)
1105 1107 "You do not have execute access on that directory"); "You do not have execute access on that directory");
1106 1108
1107 1109 clean_selected_files(view); clean_selected_files(view);
1108 return;
1110 return -1;
1109 1111 } }
1110 1112
1111 1113 dir = opendir(dir_dup); dir = opendir(dir_dup);
 
... ... change_directory(FileView *view, const char *directory)
1114 1116 { {
1115 1117 show_error_msg("Dir is null", "Could not open directory. "); show_error_msg("Dir is null", "Could not open directory. ");
1116 1118 clean_selected_files(view); clean_selected_files(view);
1117 return;
1119 return -1;
1118 1120 } }
1119 1121
1120 1122 if(chdir(dir_dup) == -1) if(chdir(dir_dup) == -1)
1121 1123 { {
1122 1124 closedir(dir); closedir(dir);
1123 1125 status_bar_message("Couldn't open directory"); status_bar_message("Couldn't open directory");
1124 return;
1126 return -1;
1125 1127 } }
1126 1128
1127 1129 clean_selected_files(view); clean_selected_files(view);
 
... ... change_directory(FileView *view, const char *directory)
1142 1144 closedir(dir); closedir(dir);
1143 1145
1144 1146 save_view_history(view); save_view_history(view);
1147 return 0;
1145 1148 } }
1146 1149
1147 1150 static void static void
 
... ... load_dir_list(FileView *view, int reload)
1367 1370 draw_dir_list(view, view->top_line, view->list_pos); draw_dir_list(view, view->top_line, view->list_pos);
1368 1371 } }
1369 1372
1370 bool
1371 is_link_dir(const dir_entry_t * path)
1372 {
1373 struct stat s;
1374 stat(path->name, &s);
1375
1376 //if(s.st_mode & S_IFMT == S_IFDIR) return true;
1377 if(s.st_mode & S_IFDIR)
1378 return true;
1379 else
1380 return false;
1381 }
1382
1383 1373 void void
1384 1374 filter_selected_files(FileView *view) filter_selected_files(FileView *view)
1385 1375 { {
 
... ... check_if_filelists_have_changed(FileView *view)
1575 1565
1576 1566 if(stat(view->curr_dir, &s) != 0) if(stat(view->curr_dir, &s) != 0)
1577 1567 { {
1578 show_error_msg(" Directory Access Error ",
1579 "Cannot open directory");
1568 show_error_msg(" Directory Access Error ", "Cannot open directory");
1580 1569 leave_invalid_dir(view, view->curr_dir); leave_invalid_dir(view, view->curr_dir);
1581 1570 change_directory(view, view->curr_dir); change_directory(view, view->curr_dir);
1582 1571 clean_selected_files(view); clean_selected_files(view);
File src/filelist.h changed (mode: 100644) (index 420625e52..bc1e3604d)
... ... void friendly_size_notation(unsigned long long num, int str_size, char *str);
35 35 void quick_view_file(FileView * view); void quick_view_file(FileView * view);
36 36 void clean_selected_files(FileView *view); void clean_selected_files(FileView *view);
37 37 void goto_history_pos(FileView *view, int pos); void goto_history_pos(FileView *view, int pos);
38 void change_directory(FileView *view, const char *directory);
38 int change_directory(FileView *view, const char *directory);
39 39 void load_dir_list(FileView *view, int reload); void load_dir_list(FileView *view, int reload);
40 40 void draw_dir_list(FileView *view, int top, int pos); void draw_dir_list(FileView *view, int top, int pos);
41 41 char * get_current_file_name(FileView *view); char * get_current_file_name(FileView *view);
 
... ... void get_all_selected_files(FileView *view);
45 45 void get_selected_files(FileView *view, int count, int *indexes); void get_selected_files(FileView *view, int count, int *indexes);
46 46 void free_selected_file_array(FileView *view); void free_selected_file_array(FileView *view);
47 47 void erase_current_line_bar(FileView *view); void erase_current_line_bar(FileView *view);
48 bool is_link_dir(const dir_entry_t * path);
49 48 void filter_selected_files(FileView *view); void filter_selected_files(FileView *view);
50 49 void hide_dot_files(FileView *view); void hide_dot_files(FileView *view);
51 50 void show_dot_files(FileView *view); void show_dot_files(FileView *view);
File src/fileops.c changed (mode: 100644) (index a43486162..037ad4b21)
... ... handle_file(FileView *view, int dont_execute)
290 290
291 291 if(strcmp(filename, "../") == 0) if(strcmp(filename, "../") == 0)
292 292 cd_updir(view); cd_updir(view);
293 else
293 else if(change_directory(view, filename) == 0)
294 294 { {
295 change_directory(view, filename);
296 295 load_dir_list(view, 0); load_dir_list(view, 0);
297 296 moveto_list_pos(view, view->curr_line); moveto_list_pos(view, view->curr_line);
298 297 } }
File src/sort.c changed (mode: 100644) (index 356cb872a..bc345b037)
16 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17 17 */ */
18 18
19 #include <fcntl.h> /* access */
19 20 #include <ncurses.h> #include <ncurses.h>
20 21 #include <string.h> /* strrchr */ #include <string.h> /* strrchr */
21 22
22 23 #include "filelist.h" #include "filelist.h"
23 24 #include "ui.h" #include "ui.h"
24 25
26 bool
27 is_link_dir(const dir_entry_t * path)
28 {
29 struct stat s;
30 stat(path->name, &s);
31
32 return (s.st_mode & S_IFDIR);
33 }
34
25 35 /* /*
26 36 * This function is from the git program written by Tudor Hulubei and * This function is from the git program written by Tudor Hulubei and
27 37 * Andrei Pitis * Andrei Pitis
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vifm

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vifm

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master