File src/filelist.h changed (mode: 100644) (index acc7c2b1a..2a6fb7bee) |
... |
... |
void save_view_history(FileView *view, const char path[], const char file[], |
178 |
178 |
int is_in_view_history(FileView *view, const char *path); |
int is_in_view_history(FileView *view, const char *path); |
179 |
179 |
void clean_positions_in_history(FileView *view); |
void clean_positions_in_history(FileView *view); |
180 |
180 |
|
|
181 |
|
/* Typed (with trailing slash for directories) file name functions. */ |
|
|
181 |
|
/* Typed (with trailing slash for directories) file name function. */ |
182 |
182 |
|
|
183 |
183 |
/* Gets typed path for the entry. On return allocates memory, that should be |
/* Gets typed path for the entry. On return allocates memory, that should be |
184 |
184 |
* freed by the caller. */ |
* freed by the caller. */ |
185 |
185 |
char * get_typed_entry_fpath(const dir_entry_t *entry); |
char * get_typed_entry_fpath(const dir_entry_t *entry); |
186 |
|
/* Gets typed filename (not path, just name) for the entry. Allocates memory, |
|
187 |
|
* that should be freed by the caller. */ |
|
188 |
|
char * get_typed_entry_fname(const dir_entry_t *entry); |
|
189 |
186 |
|
|
190 |
187 |
/* Custom file list functions. */ |
/* Custom file list functions. */ |
191 |
188 |
|
|
File src/running.c changed (mode: 100644) (index 667ce16c2..f587fe3d6) |
... |
... |
run_file(FileView *view, int dont_execute) |
421 |
421 |
char *typed_fname; |
char *typed_fname; |
422 |
422 |
const char *entry_prog_cmd; |
const char *entry_prog_cmd; |
423 |
423 |
|
|
424 |
|
if(!path_exists(entry->name, DEREF)) |
|
|
424 |
|
if(!path_exists_at(entry->origin, entry->name, DEREF)) |
425 |
425 |
{ |
{ |
426 |
426 |
show_error_msgf("Broken Link", "Destination of \"%s\" link doesn't exist", |
show_error_msgf("Broken Link", "Destination of \"%s\" link doesn't exist", |
427 |
427 |
entry->name); |
entry->name); |
428 |
428 |
return; |
return; |
429 |
429 |
} |
} |
430 |
430 |
|
|
431 |
|
typed_fname = get_typed_entry_fname(entry); |
|
|
431 |
|
typed_fname = get_typed_entry_fpath(entry); |
432 |
432 |
entry_prog_cmd = ft_get_program(typed_fname); |
entry_prog_cmd = ft_get_program(typed_fname); |
433 |
433 |
free(typed_fname); |
free(typed_fname); |
434 |
434 |
|
|
|
... |
... |
run_selection_separately(FileView *view, int dont_execute) |
510 |
510 |
char *typed_fname; |
char *typed_fname; |
511 |
511 |
const char *entry_prog_cmd; |
const char *entry_prog_cmd; |
512 |
512 |
|
|
513 |
|
typed_fname = get_typed_entry_fname(entry); |
|
|
513 |
|
typed_fname = get_typed_entry_fpath(entry); |
514 |
514 |
entry_prog_cmd = ft_get_program(typed_fname); |
entry_prog_cmd = ft_get_program(typed_fname); |
515 |
515 |
free(typed_fname); |
free(typed_fname); |
516 |
516 |
|
|
File tests/misc/running.c added (mode: 100644) (index 000000000..61bf07a2f) |
|
1 |
|
#include <stic.h> |
|
2 |
|
|
|
3 |
|
#include <unistd.h> /* chdir() */ |
|
4 |
|
|
|
5 |
|
#include <stddef.h> /* NULL */ |
|
6 |
|
#include <stdio.h> /* snprintf() */ |
|
7 |
|
#include <string.h> /* strdup() */ |
|
8 |
|
|
|
9 |
|
#include "../../src/cfg/config.h" |
|
10 |
|
#include "../../src/utils/dynarray.h" |
|
11 |
|
#include "../../src/utils/fs.h" |
|
12 |
|
#include "../../src/utils/matcher.h" |
|
13 |
|
#include "../../src/utils/path.h" |
|
14 |
|
#include "../../src/utils/str.h" |
|
15 |
|
#include "../../src/filelist.h" |
|
16 |
|
#include "../../src/filetype.h" |
|
17 |
|
#include "../../src/running.h" |
|
18 |
|
#include "../../src/status.h" |
|
19 |
|
|
|
20 |
|
static int prog_exists(const char name[]); |
|
21 |
|
|
|
22 |
|
SETUP() |
|
23 |
|
{ |
|
24 |
|
#ifndef _WIN32 |
|
25 |
|
update_string(&cfg.shell, "/bin/sh"); |
|
26 |
|
#else |
|
27 |
|
update_string(&cfg.shell, "cmd"); |
|
28 |
|
#endif |
|
29 |
|
|
|
30 |
|
update_string(&cfg.vi_command, "echo"); |
|
31 |
|
|
|
32 |
|
stats_update_shell_type(cfg.shell); |
|
33 |
|
|
|
34 |
|
lwin.list_rows = 2; |
|
35 |
|
lwin.list_pos = 0; |
|
36 |
|
lwin.dir_entry = dynarray_cextend(NULL, |
|
37 |
|
lwin.list_rows*sizeof(*lwin.dir_entry)); |
|
38 |
|
lwin.dir_entry[0].name = strdup("a"); |
|
39 |
|
lwin.dir_entry[0].origin = &lwin.curr_dir[0]; |
|
40 |
|
lwin.dir_entry[0].selected = 1; |
|
41 |
|
lwin.dir_entry[1].name = strdup("b"); |
|
42 |
|
lwin.dir_entry[1].origin = &lwin.curr_dir[0]; |
|
43 |
|
lwin.dir_entry[1].selected = 1; |
|
44 |
|
lwin.selected_files = 2; |
|
45 |
|
curr_view = &lwin; |
|
46 |
|
|
|
47 |
|
ft_init(&prog_exists); |
|
48 |
|
|
|
49 |
|
if(is_path_absolute(TEST_DATA_PATH)) |
|
50 |
|
{ |
|
51 |
|
snprintf(lwin.curr_dir, sizeof(lwin.curr_dir), "%s/existing-files", |
|
52 |
|
TEST_DATA_PATH); |
|
53 |
|
} |
|
54 |
|
else |
|
55 |
|
{ |
|
56 |
|
char cwd[PATH_MAX]; |
|
57 |
|
assert_non_null(get_cwd(cwd, sizeof(cwd))); |
|
58 |
|
|
|
59 |
|
snprintf(lwin.curr_dir, sizeof(lwin.curr_dir), "%s/%s/existing-files", cwd, |
|
60 |
|
TEST_DATA_PATH); |
|
61 |
|
} |
|
62 |
|
} |
|
63 |
|
|
|
64 |
|
TEARDOWN() |
|
65 |
|
{ |
|
66 |
|
int i; |
|
67 |
|
|
|
68 |
|
update_string(&cfg.shell, NULL); |
|
69 |
|
stats_update_shell_type("/bin/sh"); |
|
70 |
|
|
|
71 |
|
for(i = 0; i < lwin.list_rows; ++i) |
|
72 |
|
{ |
|
73 |
|
free_dir_entry(&lwin, &lwin.dir_entry[i]); |
|
74 |
|
} |
|
75 |
|
dynarray_free(lwin.dir_entry); |
|
76 |
|
|
|
77 |
|
ft_reset(0); |
|
78 |
|
update_string(&cfg.vi_command, NULL); |
|
79 |
|
} |
|
80 |
|
|
|
81 |
|
TEST(full_path_regexps_are_handled_for_selection) |
|
82 |
|
{ |
|
83 |
|
matcher_t *m; |
|
84 |
|
char pattern[PATH_MAX]; |
|
85 |
|
char *error; |
|
86 |
|
|
|
87 |
|
/* Mind that there is no chdir(), this additionally checks that origins are |
|
88 |
|
* being used by the code. */ |
|
89 |
|
|
|
90 |
|
snprintf(pattern, sizeof(pattern), "//%s/*//", lwin.curr_dir); |
|
91 |
|
m = matcher_alloc(pattern, 0, 1, &error); |
|
92 |
|
assert_non_null(m); |
|
93 |
|
ft_set_programs(m, "echo %f >> " SANDBOX_PATH "/run", 0, 1); |
|
94 |
|
|
|
95 |
|
open_file(&lwin, FHE_NO_RUN); |
|
96 |
|
|
|
97 |
|
/* Checking for file existence on its removal. */ |
|
98 |
|
assert_success(remove(SANDBOX_PATH "/run")); |
|
99 |
|
} |
|
100 |
|
|
|
101 |
|
TEST(full_path_regexps_are_handled_for_selection2) |
|
102 |
|
{ |
|
103 |
|
matcher_t *m; |
|
104 |
|
char pattern[PATH_MAX]; |
|
105 |
|
char *error; |
|
106 |
|
|
|
107 |
|
/* Mind that there is no chdir(), this additionally checks that origins are |
|
108 |
|
* being used by the code. */ |
|
109 |
|
|
|
110 |
|
snprintf(pattern, sizeof(pattern), "//%s/*//", lwin.curr_dir); |
|
111 |
|
m = matcher_alloc(pattern, 0, 1, &error); |
|
112 |
|
assert_non_null(m); |
|
113 |
|
ft_set_programs(m, "echo %c &", 0, 1); |
|
114 |
|
|
|
115 |
|
open_file(&lwin, FHE_NO_RUN); |
|
116 |
|
|
|
117 |
|
/* If we don't crash, then everything is fine. */ |
|
118 |
|
} |
|
119 |
|
|
|
120 |
|
static int |
|
121 |
|
prog_exists(const char name[]) |
|
122 |
|
{ |
|
123 |
|
return 1; |
|
124 |
|
} |
|
125 |
|
|
|
126 |
|
/* vim: set tabstop=2 softtabstop=2 shiftwidth=2 noexpandtab cinoptions-=(0 : */ |
|
127 |
|
/* vim: set cinoptions+=t0 filetype=c : */ |