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 55767a3582d796640ac06712213dbb4ed93dacc0

Fixed a bug with relative paths in arguments.
Author: xaizek
Author date (UTC): 2011-06-10 08:30
Committer name: xaizek
Committer date (UTC): 2011-06-10 08:30
Parent(s): 3e948df526b414e1bdcfa8004ece584b8ff45786
Signing key:
Tree: 0739a77cabb4d43640d3c46adfc04922a085ae6f
File Lines added Lines deleted
AUTHORS 2 0
README 1 0
src/filelist.c 5 5
src/filelist.h 1 0
src/vifm.c 16 4
File AUTHORS changed (mode: 100644) (index fd9397c42..fb1093209)
1 1 All suggestions or complaints should be sent to xaizek@gmail.com. All suggestions or complaints should be sent to xaizek@gmail.com.
2 2
3 Real author is Ken Steen ksteen@users.sourceforge.net.
4
3 5 The pauseme script is from the tkdesk program. The pauseme script is from the tkdesk program.
4 6
5 7 Some of the code is from emelfm by Michael Clark. Some of the code is from emelfm by Michael Clark.
File README changed (mode: 100644) (index cef917fa5..20316e749)
... ... src/signals.c - handlers for different signals
31 31 src/sort.c - sort function src/sort.c - sort function
32 32 src/sort_dialog.c - dialog to choose sort type src/sort_dialog.c - dialog to choose sort type
33 33 src/status.c - definition of global status structure src/status.c - definition of global status structure
34 src/tree.c - cache for ga command results
34 35 src/ui.c - setup_ncurses_interface() and other ui related functions src/ui.c - setup_ncurses_interface() and other ui related functions
35 36 src/utils.c - various utilities (e.g. functions to handle utf8 strings) src/utils.c - various utilities (e.g. functions to handle utf8 strings)
36 37 src/vifm.c - contains main() which does basic initialization src/vifm.c - contains main() which does basic initialization
File src/filelist.c changed (mode: 100644) (index 7dff16a89..f110870bc)
... ... clean_selected_files(FileView *view)
922 922 view->selected_files = 0; view->selected_files = 0;
923 923 } }
924 924
925 static void
926 canonicalize_path(const char *directory, char *buf)
925 void
926 canonicalize_path(const char *directory, char *buf, size_t buf_size)
927 927 { {
928 928 const char *p; const char *p;
929 929 char *q; char *q;
 
... ... canonicalize_path(const char *directory, char *buf)
932 932
933 933 q = buf - 1; q = buf - 1;
934 934 p = directory; p = directory;
935 while(*p != '\0')
935 while(*p != '\0' && (q + 1) - buf < buf_size - 1)
936 936 { {
937 937 int prev_dir_present = (q != buf - 1 && *q == '/'); int prev_dir_present = (q != buf - 1 && *q == '/');
938 938 if(prev_dir_present && strncmp(p, "./", 2) == 0) if(prev_dir_present && strncmp(p, "./", 2) == 0)
 
... ... change_directory(FileView *view, const char *directory)
1007 1007 save_view_history(view); save_view_history(view);
1008 1008
1009 1009 if(directory[0] == '/') if(directory[0] == '/')
1010 canonicalize_path(directory, dir_dup);
1010 canonicalize_path(directory, dir_dup, sizeof(dir_dup));
1011 1011 else else
1012 1012 { {
1013 1013 snprintf(newdir, sizeof(newdir), "%s/%s", view->curr_dir, directory); snprintf(newdir, sizeof(newdir), "%s/%s", view->curr_dir, directory);
1014 canonicalize_path(newdir, dir_dup);
1014 canonicalize_path(newdir, dir_dup, sizeof(dir_dup));
1015 1015 } }
1016 1016
1017 1017 snprintf(view->last_dir, sizeof(view->last_dir), "%s", view->curr_dir); snprintf(view->last_dir, sizeof(view->last_dir), "%s", view->curr_dir);
File src/filelist.h changed (mode: 100644) (index f32883b68..ad5126626)
... ... enum {
34 34 void friendly_size_notation(unsigned long long num, int str_size, char *str); 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 void canonicalize_path(const char *directory, char *buf, size_t buf_size);
37 38 void goto_history_pos(FileView *view, int pos); void goto_history_pos(FileView *view, int pos);
38 39 int change_directory(FileView *view, const char *directory); int change_directory(FileView *view, const char *directory);
39 40 void load_dir_list(FileView *view, int reload); void load_dir_list(FileView *view, int reload);
File src/vifm.c changed (mode: 100644) (index f92dee7c1..ee6663b61)
... ... main(int argc, char *argv[])
217 217 { {
218 218 if(lwin_args) if(lwin_args)
219 219 { {
220 snprintf(rwin.curr_dir, sizeof(rwin.curr_dir),
221 "%s", argv[x]);
220 if(argv[x][0] == '/')
221 snprintf(rwin.curr_dir, sizeof(rwin.curr_dir), "%s", argv[x]);
222 else
223 {
224 char buf[PATH_MAX];
225 snprintf(buf, sizeof(buf), "%s/%s", dir, argv[x]);
226 canonicalize_path(buf, rwin.curr_dir, sizeof(rwin.curr_dir));
227 }
222 228 rwin_args++; rwin_args++;
223 229 } }
224 230 else else
225 231 { {
226 snprintf(lwin.curr_dir, sizeof(lwin.curr_dir),
227 "%s", argv[x]);
232 if(argv[x][0] == '/')
233 snprintf(lwin.curr_dir, sizeof(lwin.curr_dir), "%s", argv[x]);
234 else
235 {
236 char buf[PATH_MAX];
237 snprintf(buf, sizeof(buf), "%s/%s", dir, argv[x]);
238 canonicalize_path(buf, lwin.curr_dir, sizeof(lwin.curr_dir));
239 }
228 240 lwin_args++; lwin_args++;
229 241 } }
230 242 } }
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