annotate runtime/autoload/tar.vim @ 21123:c707f5c7d8b3

Added tag v8.2.1112 for changeset 839ace6773aaa18625796440c5d0736a624984fb
author Bram Moolenaar <Bram@vim.org>
date Wed, 01 Jul 2020 20:15:04 +0200
parents 9b7f90e56753
children 29c5f168c6fd
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
1 " tar.vim: Handles browsing tarfiles
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
2 " AUTOLOAD PORTION
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
3 " Date: Jan 07, 2020
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
4 " Version: 32
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
5 " Maintainer: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
6 " License: Vim License (see vim's :help license)
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
7 "
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
8 " Contains many ideas from Michael Toren's <tar.vim>
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
9 "
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
10 " Copyright: Copyright (C) 2005-2017 Charles E. Campbell {{{1
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
11 " Permission is hereby granted to use and distribute this code,
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
12 " with or without modifications, provided that this copyright
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
13 " notice is copied with it. Like anything else that's free,
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
14 " tar.vim and tarPlugin.vim are provided *as is* and comes
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
15 " with no warranty of any kind, either expressed or implied.
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
16 " By using this plugin, you agree that in no event will the
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
17 " copyright holder be liable for any damages resulting from
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
18 " the use of this software.
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
19 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
20 " ---------------------------------------------------------------------
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
21 " Load Once: {{{1
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
22 if &cp || exists("g:loaded_tar")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
23 finish
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
24 endif
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
25 let g:loaded_tar= "v32"
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
26 if v:version < 702
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
27 echohl WarningMsg
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
28 echo "***warning*** this version of tar needs vim 7.2"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
29 echohl Normal
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
30 finish
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
31 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
32 let s:keepcpo= &cpo
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
33 set cpo&vim
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
34 "DechoTabOn
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
35 "call Decho("loading autoload/tar.vim")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
36
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
37 " ---------------------------------------------------------------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
38 " Default Settings: {{{1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
39 if !exists("g:tar_browseoptions")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
40 let g:tar_browseoptions= "Ptf"
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
41 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
42 if !exists("g:tar_readoptions")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
43 let g:tar_readoptions= "OPxf"
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
44 endif
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
45 if !exists("g:tar_cmd")
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
46 let g:tar_cmd= "tar"
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
47 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
48 if !exists("g:tar_writeoptions")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
49 let g:tar_writeoptions= "uf"
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
50 endif
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
51 if !exists("g:tar_delfile")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
52 let g:tar_delfile="--delete -f"
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
53 endif
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
54 if !exists("g:netrw_cygwin")
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
55 if has("win32") || has("win95") || has("win64") || has("win16")
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
56 if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
57 let g:netrw_cygwin= 1
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
58 else
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
59 let g:netrw_cygwin= 0
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
60 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
61 else
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
62 let g:netrw_cygwin= 0
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
63 endif
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
64 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
65 if !exists("g:tar_copycmd")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
66 if !exists("g:netrw_localcopycmd")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
67 if has("win32") || has("win95") || has("win64") || has("win16")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
68 if g:netrw_cygwin
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
69 let g:netrw_localcopycmd= "cp"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
70 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
71 let g:netrw_localcopycmd= "copy"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
72 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
73 elseif has("unix") || has("macunix")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
74 let g:netrw_localcopycmd= "cp"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
75 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
76 let g:netrw_localcopycmd= ""
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
77 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
78 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
79 let g:tar_copycmd= g:netrw_localcopycmd
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
80 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
81 if !exists("g:tar_extractcmd")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
82 let g:tar_extractcmd= "tar -xf"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
83 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
84
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
85 " set up shell quoting character
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
86 if !exists("g:tar_shq")
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
87 if exists("+shq") && exists("&shq") && &shq != ""
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
88 let g:tar_shq= &shq
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
89 elseif has("win32") || has("win95") || has("win64") || has("win16")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
90 if exists("g:netrw_cygwin") && g:netrw_cygwin
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
91 let g:tar_shq= "'"
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
92 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
93 let g:tar_shq= '"'
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
94 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
95 else
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
96 let g:tar_shq= "'"
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
97 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
98 " call Decho("g:tar_shq<".g:tar_shq.">")
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
99 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
100
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
101 " ----------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
102 " Functions: {{{1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
103 " ----------------
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
104
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
105 " ---------------------------------------------------------------------
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
106 " tar#Browse: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
107 fun! tar#Browse(tarfile)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
108 " call Dfunc("tar#Browse(tarfile<".a:tarfile.">)")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
109 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
110 set report=10
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
111
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
112 " sanity checks
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
113 if !executable(g:tar_cmd)
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
114 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
115 " call Decho('***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
116 echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
117 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
118 " call Dret("tar#Browse")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
119 return
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
120 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
121 if !filereadable(a:tarfile)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
122 " call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
123 if a:tarfile !~# '^\a\+://'
19116
9b7f90e56753 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 19099
diff changeset
124 " if it's an url, don't complain, let url-handlers such as vim do its thing
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
125 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
126 " call Decho("***error*** (tar#Browse) File not readable<".a:tarfile.">")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
127 echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
128 endif
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
129 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
130 " call Dret("tar#Browse : file<".a:tarfile."> not readable")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
131 return
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
132 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
133 if &ma != 1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
134 set ma
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
135 endif
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
136 let b:tarfile= a:tarfile
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
137
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
138 setlocal noswapfile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
139 setlocal buftype=nofile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
140 setlocal bufhidden=hide
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
141 setlocal nobuflisted
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
142 setlocal nowrap
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
143 set ft=tar
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
144
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
145 " give header
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
146 " call Decho("printing header")
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
147 let lastline= line("$")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
148 call setline(lastline+1,'" tar.vim version '.g:loaded_tar)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
149 call setline(lastline+2,'" Browsing tarfile '.a:tarfile)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
150 call setline(lastline+3,'" Select a file with cursor and press ENTER')
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
151 keepj $put =''
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
152 keepj sil! 0d
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
153 keepj $
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
154
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
155 let tarfile= a:tarfile
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
156 if has("win32unix") && executable("cygpath")
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
157 " assuming cygwin
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
158 let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
159 endif
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
160 let curlast= line("$")
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 14637
diff changeset
161
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
162 if tarfile =~# '\.\(gz\)$'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
163 " call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
164 exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
165
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
166 elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$'
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
167 if has("unix") && executable("file")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
168 let filekind= system("file ".shellescape(tarfile,1)) =~ "bzip2"
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
169 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
170 let filekind= ""
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
171 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
172
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
173 if filekind =~ "bzip2"
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
174 exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
175 elseif filekind =~ "XZ"
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
176 exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
177 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
178 exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
179 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
180
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
181 elseif tarfile =~# '\.lrp'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
182 " call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
14679
ba010fa2bcba patch 8.1.0352: browsing compressed tar files does not always work
Christian Brabandt <cb@256bit.org>
parents: 14668
diff changeset
183 exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
184 elseif tarfile =~# '\.\(bz2\|tbz\|tb2\)$'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
185 " call Decho("3: exe silent r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
186 exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
3281
af1e8a1714c2 Update runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2908
diff changeset
187 elseif tarfile =~# '\.\(lzma\|tlz\)$'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
188 " call Decho("3: exe silent r! lzma -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
189 exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
2426
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
190 elseif tarfile =~# '\.\(xz\|txz\)$'
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
191 " call Decho("3: exe silent r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
192 exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
193 else
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
194 if tarfile =~ '^\s*-'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
195 " A file name starting with a dash is taken as an option. Prepend ./ to avoid that.
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
196 let tarfile = substitute(tarfile, '-', './-', '')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
197 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
198 " call Decho("4: exe silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".shellescape(tarfile,0))
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
199 exe "sil! r! ".g:tar_cmd." -".g:tar_browseoptions." ".shellescape(tarfile,1)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
200 endif
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
201 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
202 redraw!
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
203 echohl WarningMsg | echo "***warning*** (tar#Browse) please check your g:tar_browseoptions<".g:tar_browseoptions.">"
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
204 " call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
205 return
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
206 endif
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
207 if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~# '\c\%(warning\|error\|inappropriate\|unrecognized\)')
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
208 redraw!
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
209 echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
210 keepj sil! %d
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
211 let eikeep= &ei
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
212 set ei=BufReadCmd,FileReadCmd
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
213 exe "r ".fnameescape(a:tarfile)
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
214 let &ei= eikeep
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
215 keepj sil! 1d
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
216 " call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
217 return
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
218 endif
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
219
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
220 " set up maps supported for tar
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
221 setlocal noma nomod ro
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
222 noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
223 noremap <silent> <buffer> x :call tar#Extract()<cr>
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
224 if &mouse != ""
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
225 noremap <silent> <buffer> <leftmouse> <leftmouse>:call <SID>TarBrowseSelect()<cr>
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
226 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
227
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
228 let &report= repkeep
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
229 " call Dret("tar#Browse : b:tarfile<".b:tarfile.">")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
230 endfun
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
231
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
232 " ---------------------------------------------------------------------
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
233 " TarBrowseSelect: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
234 fun! s:TarBrowseSelect()
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
235 " call Dfunc("TarBrowseSelect() b:tarfile<".b:tarfile."> curfile<".expand("%").">")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
236 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
237 set report=10
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
238 let fname= getline(".")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
239 " call Decho("fname<".fname.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
240
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
241 if !exists("g:tar_secure") && fname =~ '^\s*-\|\s\+-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
242 redraw!
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
243 echohl WarningMsg | echo '***warning*** (tar#BrowseSelect) rejecting tarfile member<'.fname.'> because of embedded "-"'
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
244 " call Dret('tar#BrowseSelect : rejecting tarfile member<'.fname.'> because of embedded "-"')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
245 return
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
246 endif
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
247
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
248 " sanity check
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
249 if fname =~ '^"'
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
250 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
251 " call Dret("TarBrowseSelect")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
252 return
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
253 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
254
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
255 " about to make a new window, need to use b:tarfile
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
256 let tarfile= b:tarfile
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
257 let curfile= expand("%")
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
258 if has("win32unix") && executable("cygpath")
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
259 " assuming cygwin
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
260 let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
261 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
262
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
263 " open a new window (tar#Read will read a file into it)
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
264 noswapfile new
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
265 if !exists("g:tar_nomax") || g:tar_nomax == 0
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
266 wincmd _
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
267 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
268 let s:tblfile_{winnr()}= curfile
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
269 call tar#Read("tarfile:".tarfile.'::'.fname,1)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
270 filetype detect
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
271 set nomod
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
272 exe 'com! -buffer -nargs=? -complete=file TarDiff :call tar#Diff(<q-args>,"'.fnameescape(fname).'")'
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
273
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
274 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
275 " call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
276 endfun
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
277
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
278 " ---------------------------------------------------------------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
279 " tar#Read: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
280 fun! tar#Read(fname,mode)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
281 " call Dfunc("tar#Read(fname<".a:fname.">,mode=".a:mode.")")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
282 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
283 set report=10
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
284 let tarfile = substitute(a:fname,'tarfile:\(.\{-}\)::.*$','\1','')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
285 let fname = substitute(a:fname,'tarfile:.\{-}::\(.*\)$','\1','')
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
286 if has("win32unix") && executable("cygpath")
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
287 " assuming cygwin
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
288 let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
289 endif
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
290 " call Decho("tarfile<".tarfile.">")
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
291 " call Decho("fname<".fname.">")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
292
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
293 if fname =~ '\.bz2$' && executable("bzcat")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
294 let decmp= "|bzcat"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
295 let doro = 1
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
296 elseif fname =~ '\.t\=gz$' && executable("zcat")
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
297 let decmp= "|zcat"
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
298 let doro = 1
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
299 elseif fname =~ '\.lzma$' && executable("lzcat")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
300 let decmp= "|lzcat"
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
301 let doro = 1
2426
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
302 elseif fname =~ '\.xz$' && executable("xzcat")
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
303 let decmp= "|xzcat"
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
304 let doro = 1
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
305 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
306 let decmp=""
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
307 let doro = 0
2426
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
308 if fname =~ '\.bz2$\|\.gz$\|\.lzma$\|\.xz$\|\.zip$\|\.Z$'
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
309 setlocal bin
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
310 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
311 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
312
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
313 if exists("g:tar_secure")
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
314 let tar_secure= " -- "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
315 else
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
316 let tar_secure= " "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
317 endif
14668
34fd018452ed Update runtime files.
Christian Brabandt <cb@256bit.org>
parents: 14637
diff changeset
318
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
319 if tarfile =~# '\.bz2$'
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
320 exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
321 elseif tarfile =~# '\.\(gz\)$'
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
322 exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
323
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
324 elseif tarfile =~# '\(\.tgz\|\.tbz\|\.txz\)'
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
325 if has("unix") && executable("file")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
326 let filekind= system("file ".shellescape(tarfile,1))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
327 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
328 let filekind= ""
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
329 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
330 if filekind =~ "bzip2"
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
331 exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
332 elseif filekind =~ "XZ"
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
333 exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
334 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
335 exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
336 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
337
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
338 elseif tarfile =~# '\.lrp$'
14679
ba010fa2bcba patch 8.1.0352: browsing compressed tar files does not always work
Christian Brabandt <cb@256bit.org>
parents: 14668
diff changeset
339 exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
340 elseif tarfile =~# '\.lzma$'
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
341 exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
2426
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
342 elseif tarfile =~# '\.\(xz\|txz\)$'
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
343 exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
344 else
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
345 if tarfile =~ '^\s*-'
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
346 " A file name starting with a dash is taken as an option. Prepend ./ to avoid that.
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
347 let tarfile = substitute(tarfile, '-', './-', '')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
348 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
349 " call Decho("8: exe silent r! ".g:tar_cmd." -".g:tar_readoptions.tar_secure.shellescape(tarfile,1)." ".shellescape(fname,1).decmp)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
350 exe "silent r! ".g:tar_cmd." -".g:tar_readoptions.shellescape(tarfile,1)." ".tar_secure.shellescape(fname,1).decmp
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
351 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
352
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
353 if doro
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
354 " because the reverse process of compressing changed files back into the tarball is not currently supported
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
355 setlocal ro
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
356 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
357
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
358 let b:tarfile= a:fname
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
359 exe "file tarfile::".fnameescape(fname)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
360
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
361 " cleanup
2908
fd09a9c8468e Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2535
diff changeset
362 keepj sil! 0d
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
363 set nomod
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
364
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
365 let &report= repkeep
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
366 " call Dret("tar#Read : b:tarfile<".b:tarfile.">")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
367 endfun
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
368
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
369 " ---------------------------------------------------------------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
370 " tar#Write: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
371 fun! tar#Write(fname)
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
372 " call Dfunc("tar#Write(fname<".a:fname.">) b:tarfile<".b:tarfile."> tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
373 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
374 set report=10
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
375
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
376 if !exists("g:tar_secure") && a:fname =~ '^\s*-\|\s\+-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
377 redraw!
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
378 echohl WarningMsg | echo '***warning*** (tar#Write) rejecting tarfile member<'.a:fname.'> because of embedded "-"'
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
379 " call Dret('tar#Write : rejecting tarfile member<'.fname.'> because of embedded "-"')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
380 return
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
381 endif
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
382
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
383 " sanity checks
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
384 if !executable(g:tar_cmd)
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
385 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
386 " call Decho('***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system')
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
387 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
388 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
389 return
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
390 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
391 if !exists("*mkdir")
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
392 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
393 " call Decho("***error*** (tar#Write) sorry, mkdir() doesn't work on your system")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
394 echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
395 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
396 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
397 return
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
398 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
399
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
400 let curdir= getcwd()
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
401 let tmpdir= tempname()
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
402 " call Decho("orig tempname<".tmpdir.">")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
403 if tmpdir =~ '\.'
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
404 let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
405 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
406 " call Decho("tmpdir<".tmpdir.">")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
407 call mkdir(tmpdir,"p")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
408
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
409 " attempt to change to the indicated directory
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
410 try
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
411 exe "cd ".fnameescape(tmpdir)
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
412 catch /^Vim\%((\a\+)\)\=:E344/
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
413 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
414 " call Decho("***error*** (tar#Write) cannot cd to temporary directory")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
415 echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
416 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
417 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
418 return
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
419 endtry
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
420 " call Decho("current directory now: ".getcwd())
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
421
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
422 " place temporary files under .../_ZIPVIM_/
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
423 if isdirectory("_ZIPVIM_")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
424 call s:Rmdir("_ZIPVIM_")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
425 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
426 call mkdir("_ZIPVIM_")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
427 cd _ZIPVIM_
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
428 " call Decho("current directory now: ".getcwd())
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
429
2535
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
430 let tarfile = substitute(b:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
31e51111bd14 Runtime file updates. Fix tar plugin window split.
Bram Moolenaar <bram@vim.org>
parents: 2426
diff changeset
431 let fname = substitute(b:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
432
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
433 " handle compressed archives
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
434 if tarfile =~# '\.bz2'
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
435 call system("bzip2 -d -- ".shellescape(tarfile,0))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
436 let tarfile = substitute(tarfile,'\.bz2','','e')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
437 let compress= "bzip2 -- ".shellescape(tarfile,0)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
438 " call Decho("compress<".compress.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
439 elseif tarfile =~# '\.gz'
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
440 call system("gzip -d -- ".shellescape(tarfile,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
441 let tarfile = substitute(tarfile,'\.gz','','e')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
442 let compress= "gzip -- ".shellescape(tarfile,0)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
443 " call Decho("compress<".compress.">")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
444 elseif tarfile =~# '\.tgz'
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
445 call system("gzip -d -- ".shellescape(tarfile,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
446 let tarfile = substitute(tarfile,'\.tgz','.tar','e')
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
447 let compress= "gzip -- ".shellescape(tarfile,0)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
448 let tgz = 1
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
449 " call Decho("compress<".compress.">")
2426
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
450 elseif tarfile =~# '\.xz'
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
451 call system("xz -d -- ".shellescape(tarfile,0))
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
452 let tarfile = substitute(tarfile,'\.xz','','e')
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
453 let compress= "xz -- ".shellescape(tarfile,0)
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
454 " call Decho("compress<".compress.">")
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
455 elseif tarfile =~# '\.lzma'
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
456 call system("lzma -d -- ".shellescape(tarfile,0))
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
457 let tarfile = substitute(tarfile,'\.lzma','','e')
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
458 let compress= "lzma -- ".shellescape(tarfile,0)
e52d87a2bb3e More runtime file updates.
Bram Moolenaar <bram@vim.org>
parents: 2034
diff changeset
459 " call Decho("compress<".compress.">")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
460 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
461 " call Decho("tarfile<".tarfile.">")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
462
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
463 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
464 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
465 " call Decho("***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
466 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
467 else
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
468
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
469 " call Decho("tarfile<".tarfile."> fname<".fname.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
470
624
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
471 if fname =~ '/'
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
472 let dirpath = substitute(fname,'/[^/]\+$','','e')
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
473 if has("win32unix") && executable("cygpath")
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
474 let dirpath = substitute(system("cygpath ".shellescape(dirpath, 0)),'\n','','e')
624
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
475 endif
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
476 call mkdir(dirpath,"p")
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
477 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
478 if tarfile !~ '/'
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
479 let tarfile= curdir.'/'.tarfile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
480 endif
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
481 if tarfile =~ '^\s*-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
482 " A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
483 let tarfile = substitute(tarfile, '-', './-', '')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
484 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
485 " call Decho("tarfile<".tarfile."> fname<".fname.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
486
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
487 if exists("g:tar_secure")
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
488 let tar_secure= " -- "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
489 else
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
490 let tar_secure= " "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
491 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
492 exe "w! ".fnameescape(fname)
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
493 if has("win32unix") && executable("cygpath")
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
494 let tarfile = substitute(system("cygpath ".shellescape(tarfile,0)),'\n','','e')
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
495 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
496
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
497 " delete old file from tarfile
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
498 " call Decho("system(".g:tar_cmd." ".g:tar_delfile." ".shellescape(tarfile,0)." -- ".shellescape(fname,0).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
499 call system(g:tar_cmd." ".g:tar_delfile." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
500 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
501 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
502 " call Decho("***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname))
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
503 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
504 else
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
505
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
506 " update tarfile with new file
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
507 " call Decho(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
508 call system(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
509 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
510 redraw!
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
511 " call Decho("***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname))
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
512 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
513 elseif exists("compress")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
514 " call Decho("call system(".compress.")")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
515 call system(compress)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
516 if exists("tgz")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
517 " call Decho("rename(".tarfile.".gz,".substitute(tarfile,'\.tar$','.tgz','e').")")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
518 call rename(tarfile.".gz",substitute(tarfile,'\.tar$','.tgz','e'))
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
519 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
520 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
521 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
522
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
523 " support writing tarfiles across a network
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
524 if s:tblfile_{winnr()} =~ '^\a\+://'
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
525 " call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
526 let tblfile= s:tblfile_{winnr()}
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
527 1split|noswapfile enew
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
528 let binkeep= &l:binary
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
529 let eikeep = &ei
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
530 set binary ei=all
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
531 exe "noswapfile e! ".fnameescape(tarfile)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
532 call netrw#NetWrite(tblfile)
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
533 let &ei = eikeep
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
534 let &l:binary = binkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
535 q!
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
536 unlet s:tblfile_{winnr()}
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
537 endif
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
538 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
539
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
540 " cleanup and restore current directory
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
541 cd ..
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
542 call s:Rmdir("_ZIPVIM_")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
543 exe "cd ".fnameescape(curdir)
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
544 setlocal nomod
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
545
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
546 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
547 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
548 endfun
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
549
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
550 " ---------------------------------------------------------------------
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
551 " tar#Diff: {{{2
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
552 fun! tar#Diff(userfname,fname)
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
553 " call Dfunc("tar#Diff(userfname<".a:userfname."> fname<".a:fname.")")
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
554 let fname= a:fname
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
555 if a:userfname != ""
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
556 let fname= a:userfname
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
557 endif
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
558 if filereadable(fname)
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
559 " sets current file (from tarball) for diff'ing
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
560 " splits window vertically
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
561 " opens original file, sets it for diff'ing
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
562 " sets up b:tardiff_otherbuf variables so each buffer knows about the other (for closing purposes)
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
563 diffthis
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
564 wincmd v
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
565 exe "noswapfile e ".fnameescape(fname)
4339
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
566 diffthis
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
567 else
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
568 redraw!
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
569 echo "***warning*** unable to read file<".fname.">"
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
570 endif
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
571 " call Dret("tar#Diff")
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
572 endfun
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
573
22fa3049e934 Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 3281
diff changeset
574 " ---------------------------------------------------------------------
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
575 " tar#Extract: extract a file from a (possibly compressed) tar archive {{{2
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
576 fun! tar#Extract()
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
577 " call Dfunc("tar#Extract()")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
578
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
579 let repkeep= &report
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
580 set report=10
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
581 let fname= getline(".")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
582 " call Decho("fname<".fname.">")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
583
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
584 if !exists("g:tar_secure") && fname =~ '^\s*-\|\s\+-'
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
585 redraw!
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
586 echohl WarningMsg | echo '***warning*** (tar#BrowseSelect) rejecting tarfile member<'.fname.'> because of embedded "-"'
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
587 " call Dret('tar#BrowseSelect : rejecting tarfile member<'.fname.'> because of embedded "-"')
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
588 return
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
589 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
590
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
591 " sanity check
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
592 if fname =~ '^"'
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
593 let &report= repkeep
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
594 " call Dret("TarBrowseSelect")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
595 return
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
596 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
597
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
598 let tarball = expand("%")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
599 " call Decho("tarball<".tarball.">")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
600 let tarbase = substitute(tarball,'\..*$','','')
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
601 " call Decho("tarbase<".tarbase.">")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
602
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
603 let extractcmd= netrw#WinPath(g:tar_extractcmd)
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
604 if filereadable(tarbase.".tar")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
605 " call Decho("system(".extractcmd." ".shellescape(tarbase).".tar ".shellescape(fname).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
606 call system(extractcmd." ".shellescape(tarbase).".tar ".shellescape(fname))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
607 if v:shell_error != 0
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
608 echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar ".fname.": failed!" | echohl NONE
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
609 " call Decho("***error*** ".extractcmd." ".tarbase.".tar ".fname.": failed!")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
610 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
611 echo "***note*** successfully extracted ".fname
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
612 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
613
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
614 elseif filereadable(tarbase.".tgz")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
615 let extractcmd= substitute(extractcmd,"-","-z","")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
616 " call Decho("system(".extractcmd." ".shellescape(tarbase).".tgz ".shellescape(fname).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
617 call system(extractcmd." ".shellescape(tarbase).".tgz ".shellescape(fname))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
618 if v:shell_error != 0
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
619 echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tgz ".fname.": failed!" | echohl NONE
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
620 " call Decho("***error*** ".extractcmd."t ".tarbase.".tgz ".fname.": failed!")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
621 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
622 echo "***note*** successfully extracted ".fname
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
623 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
624
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
625 elseif filereadable(tarbase.".tar.gz")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
626 let extractcmd= substitute(extractcmd,"-","-z","")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
627 " call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.gz ".shellescape(fname).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
628 call system(extractcmd." ".shellescape(tarbase).".tar.gz ".shellescape(fname))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
629 if v:shell_error != 0
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
630 echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.gz ".fname.": failed!" | echohl NONE
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
631 " call Decho("***error*** ".extractcmd." ".tarbase.".tar.gz ".fname.": failed!")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
632 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
633 echo "***note*** successfully extracted ".fname
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
634 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
635
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
636 elseif filereadable(tarbase.".tbz")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
637 let extractcmd= substitute(extractcmd,"-","-j","")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
638 " call Decho("system(".extractcmd." ".shellescape(tarbase).".tbz ".shellescape(fname).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
639 call system(extractcmd." ".shellescape(tarbase).".tbz ".shellescape(fname))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
640 if v:shell_error != 0
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
641 echohl Error | echo "***error*** ".extractcmd."j ".tarbase.".tbz ".fname.": failed!" | echohl NONE
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
642 " call Decho("***error*** ".extractcmd."j ".tarbase.".tbz ".fname.": failed!")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
643 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
644 echo "***note*** successfully extracted ".fname
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
645 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
646
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
647 elseif filereadable(tarbase.".tar.bz2")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
648 let extractcmd= substitute(extractcmd,"-","-j","")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
649 " call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.bz2 ".shellescape(fname).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
650 call system(extractcmd." ".shellescape(tarbase).".tar.bz2 ".shellescape(fname))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
651 if v:shell_error != 0
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
652 echohl Error | echo "***error*** ".extractcmd."j ".tarbase.".tar.bz2 ".fname.": failed!" | echohl NONE
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
653 " call Decho("***error*** ".extractcmd."j ".tarbase.".tar.bz2 ".fname.": failed!")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
654 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
655 echo "***note*** successfully extracted ".fname
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
656 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
657
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
658 elseif filereadable(tarbase.".txz")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
659 let extractcmd= substitute(extractcmd,"-","-J","")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
660 " call Decho("system(".extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
661 call system(extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
662 if v:shell_error != 0
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
663 echohl Error | echo "***error*** ".extractcmd." ".tarbase.".txz ".fname.": failed!" | echohl NONE
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
664 " call Decho("***error*** ".extractcmd." ".tarbase.".txz ".fname.": failed!")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
665 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
666 echo "***note*** successfully extracted ".fname
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
667 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
668
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
669 elseif filereadable(tarbase.".tar.xz")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
670 let extractcmd= substitute(extractcmd,"-","-J","")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
671 " call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.xz ".shellescape(fname).")")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
672 call system(extractcmd." ".shellescape(tarbase).".tar.xz ".shellescape(fname))
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
673 if v:shell_error != 0
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
674 echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.xz ".fname.": failed!" | echohl NONE
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
675 " call Decho("***error*** ".extractcmd." ".tarbase.".tar.xz ".fname.": failed!")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
676 else
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
677 echo "***note*** successfully extracted ".fname
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
678 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
679 endif
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
680
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
681 " restore option
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
682 let &report= repkeep
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
683
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
684 " call Dret("tar#Extract")
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
685 endfun
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
686
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
687 " ---------------------------------------------------------------------
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
688 " s:Rmdir: {{{2
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
689 fun! s:Rmdir(fname)
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
690 " call Dfunc("Rmdir(fname<".a:fname.">)")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
691 if has("unix")
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
692 call system("/bin/rm -rf -- ".shellescape(a:fname,0))
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
693 elseif has("win32") || has("win95") || has("win64") || has("win16")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
694 if &shell =~? "sh$"
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
695 call system("/bin/rm -rf -- ".shellescape(a:fname,0))
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
696 else
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
697 call system("del /S ".shellescape(a:fname,0))
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
698 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
699 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
700 " call Dret("Rmdir")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
701 endfun
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
702
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
703 " ---------------------------------------------------------------------
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
704 " tar#Vimuntar: installs a tarball in the user's .vim / vimfiles directory {{{2
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
705 fun! tar#Vimuntar(...)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
706 " call Dfunc("tar#Vimuntar() a:0=".a:0." a:1<".(exists("a:1")? a:1 : "-n/a-").">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
707 let tarball = expand("%")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
708 " call Decho("tarball<".tarball.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
709 let tarbase = substitute(tarball,'\..*$','','')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
710 " call Decho("tarbase<".tarbase.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
711 let tarhome = expand("%:p")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
712 if has("win32") || has("win95") || has("win64") || has("win16")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
713 let tarhome= substitute(tarhome,'\\','/','g')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
714 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
715 let tarhome= substitute(tarhome,'/[^/]*$','','')
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
716 " call Decho("tarhome<".tarhome.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
717 let tartail = expand("%:t")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
718 " call Decho("tartail<".tartail.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
719 let curdir = getcwd()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
720 " call Decho("curdir <".curdir.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
721 " set up vimhome
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
722 if a:0 > 0 && a:1 != ""
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
723 let vimhome= a:1
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
724 else
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
725 let vimhome= vimball#VimballHome()
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
726 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
727 " call Decho("vimhome<".vimhome.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
728
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
729 " call Decho("curdir<".curdir."> vimhome<".vimhome.">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
730 if simplify(curdir) != simplify(vimhome)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
731 " copy (possibly compressed) tarball to .vim/vimfiles
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
732 " call Decho(netrw#WinPath(g:tar_copycmd)." ".shellescape(tartail)." ".shellescape(vimhome))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
733 call system(netrw#WinPath(g:tar_copycmd)." ".shellescape(tartail)." ".shellescape(vimhome))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
734 " call Decho("exe cd ".fnameescape(vimhome))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
735 exe "cd ".fnameescape(vimhome)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
736 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
737 " call Decho("getcwd<".getcwd().">")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
738
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
739 " if necessary, decompress the tarball; then, extract it
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
740 if tartail =~ '\.tgz'
19099
1a951a4beee3 Update runtime files.
Bram Moolenaar <Bram@vim.org>
parents: 14679
diff changeset
741 if executable("gunzip")
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
742 silent exe "!gunzip ".shellescape(tartail)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
743 elseif executable("gzip")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
744 silent exe "!gzip -d ".shellescape(tartail)
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
745 else
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
746 echoerr "unable to decompress<".tartail."> on this sytem"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
747 if simplify(curdir) != simplify(tarhome)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
748 " remove decompressed tarball, restore directory
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
749 " call Decho("delete(".tartail.".tar)")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
750 call delete(tartail.".tar")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
751 " call Decho("exe cd ".fnameescape(curdir))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
752 exe "cd ".fnameescape(curdir)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
753 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
754 " call Dret("tar#Vimuntar")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
755 return
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
756 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
757 else
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
758 call vimball#Decompress(tartail,0)
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
759 endif
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
760 let extractcmd= netrw#WinPath(g:tar_extractcmd)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
761 " call Decho("system(".extractcmd." ".shellescape(tarbase.".tar").")")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
762 call system(extractcmd." ".shellescape(tarbase.".tar"))
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
763
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
764 " set up help
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
765 if filereadable("doc/".tarbase.".txt")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
766 " call Decho("exe helptags ".getcwd()."/doc")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
767 exe "helptags ".getcwd()."/doc"
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
768 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
769
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
770 if simplify(tarhome) != simplify(vimhome)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
771 " remove decompressed tarball, restore directory
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
772 call delete(vimhome."/".tarbase.".tar")
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
773 exe "cd ".fnameescape(curdir)
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
774 endif
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
775
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
776 " call Dret("tar#Vimuntar")
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
777 endfun
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
778
2034
7bc41231fbc7 Update runtime files.
Bram Moolenaar <bram@zimbu.org>
parents: 1702
diff changeset
779 " =====================================================================
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
780 " Modelines And Restoration: {{{1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
781 let &cpo= s:keepcpo
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
782 unlet s:keepcpo
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
783 " vim:ts=8 fdm=marker