File data/plugins/packer/README.md changed (mode: 100644) (index 5a8f31010..ed74cb01a) |
... |
... |
Archives the selected files. Optionally takes archive name. |
72 |
72 |
|
|
73 |
73 |
Operating systems: |
Operating systems: |
74 |
74 |
- working under Linux environment (tested on Gentoo, Slackware) |
- working under Linux environment (tested on Gentoo, Slackware) |
75 |
|
- not tested on Windows, please report if it doesn't work |
|
|
75 |
|
- working in Windows |
76 |
76 |
|
|
77 |
77 |
Limitations: |
Limitations: |
78 |
78 |
- extracting large tarballs is slow due to `tar tf` being slow |
- extracting large tarballs is slow due to `tar tf` being slow |
File data/plugins/packer/pack.lua changed (mode: 100644) (index 990562caf..6d92955a1) |
1 |
1 |
function pack(info) -- <<< |
function pack(info) -- <<< |
2 |
|
local files = vifm.expand('%f') |
|
|
2 |
|
local files = vifm.expand('%"f') |
3 |
3 |
if #files == 0 or |
if #files == 0 or |
4 |
4 |
files == '.' or files == './' or |
files == '.' or files == './' or |
5 |
5 |
files == '..' or files == '../' then |
files == '..' or files == '../' then |
|
... |
... |
function pack(info) -- <<< |
16 |
16 |
ext = 'tar.'..ext |
ext = 'tar.'..ext |
17 |
17 |
end |
end |
18 |
18 |
else |
else |
19 |
|
local singlefile = (vifm.expand('%c') == files) |
|
|
19 |
|
local singlefile = (vifm.expand('%"c') == files) |
20 |
20 |
local basename = singlefile and vifm.expand('%c:r:r') or vifm.expand('%d:t') |
local basename = singlefile and vifm.expand('%c:r:r') or vifm.expand('%d:t') |
21 |
21 |
outfile = string.format("%s.%s", unescape_name(basename), ext) |
outfile = string.format("%s.%s", unescape_name(basename), ext) |
22 |
22 |
end |
end |
File data/plugins/packer/unpack.lua changed (mode: 100644) (index 9e3419ca9..77108b42c) |
... |
... |
local function get_common_unpack_prefix(archive, format) -- <<< |
7 |
7 |
-- when large archives or archives with lots of files |
-- when large archives or archives with lots of files |
8 |
8 |
cmd = string.format("tar --force-local -tf %s", vifm.escape(archive)) |
cmd = string.format("tar --force-local -tf %s", vifm.escape(archive)) |
9 |
9 |
elseif format == 'zip' or format == 'rar' or format == '7z' then |
elseif format == 'zip' or format == 'rar' or format == '7z' then |
10 |
|
cmd = string.format("7z -ba l %s | awk '{($3 ~ /^D/) ? $0=$0\"/\" : $0; print substr($0,54) }'", |
|
11 |
|
vifm.escape(archive)) |
|
|
10 |
|
cmd = string.format("7z -ba l %s | awk %s", |
|
11 |
|
vifm.escape(archive), |
|
12 |
|
vifm.escape('{($3 ~ /^D/) ? $0=$0"/" : $0; print substr($0,54) }')) |
12 |
13 |
else |
else |
13 |
14 |
return nil, 'unsupported format: '..format |
return nil, 'unsupported format: '..format |
14 |
15 |
end |
end |
|
... |
... |
local function get_common_unpack_prefix(archive, format) -- <<< |
17 |
18 |
local prefix |
local prefix |
18 |
19 |
local prefix_len |
local prefix_len |
19 |
20 |
for line in job:stdout():lines() do |
for line in job:stdout():lines() do |
|
21 |
|
-- this conversion is really just for Windows, but there is currently no |
|
22 |
|
-- way of checking whether we're running on Windows |
|
23 |
|
-- |
|
24 |
|
-- Unix systems can allow slashes in file names in which case we might end |
|
25 |
|
-- up computing incorrect prefix, but it's a highly unlikely corner case |
|
26 |
|
line = line:gsub('\\', '/') |
|
27 |
|
|
20 |
28 |
vifm.sb.quick("Checking: "..line) |
vifm.sb.quick("Checking: "..line) |
21 |
29 |
if prefix == nil then |
if prefix == nil then |
22 |
30 |
prefix = line |
prefix = line |