557
|
1 " tar.vim: Handles browsing tarfiles
|
|
2 " AUTOLOAD PORTION
|
1702
|
3 " Date: Aug 08, 2008
|
|
4 " Version: 23 + modifications by Bram
|
1125
|
5 " Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
|
557
|
6 " License: Vim License (see vim's :help license)
|
446
|
7 "
|
557
|
8 " Contains many ideas from Michael Toren's <tar.vim>
|
446
|
9 "
|
1624
|
10 " Copyright: Copyright (C) 2005-2008 Charles E. Campbell, Jr. {{{1
|
557
|
11 " Permission is hereby granted to use and distribute this code,
|
|
12 " with or without modifications, provided that this copyright
|
|
13 " notice is copied with it. Like anything else that's free,
|
1624
|
14 " tar.vim and tarPlugin.vim are provided *as is* and comes
|
|
15 " with no warranty of any kind, either expressed or implied.
|
|
16 " By using this plugin, you agree that in no event will the
|
|
17 " copyright holder be liable for any damages resulting from
|
|
18 " the use of this software.
|
557
|
19
|
|
20 " ---------------------------------------------------------------------
|
1125
|
21 " Load Once: {{{1
|
557
|
22 let s:keepcpo= &cpo
|
|
23 set cpo&vim
|
1125
|
24 if &cp || exists("g:loaded_tar") || v:version < 700
|
527
|
25 finish
|
|
26 endif
|
1702
|
27 let g:loaded_tar= "v23b"
|
819
|
28 "call Decho("loading autoload/tar.vim")
|
1624
|
29 if v:version < 701 || (v:version == 701 && !has("patch299"))
|
|
30 echoerr "(autoload/tar.vim) need vim v7.1 with patchlevel 299"
|
|
31 endif
|
557
|
32
|
|
33 " ---------------------------------------------------------------------
|
|
34 " Default Settings: {{{1
|
|
35 if !exists("g:tar_browseoptions")
|
|
36 let g:tar_browseoptions= "Ptf"
|
|
37 endif
|
|
38 if !exists("g:tar_readoptions")
|
|
39 let g:tar_readoptions= "OPxf"
|
|
40 endif
|
819
|
41 if !exists("g:tar_cmd")
|
|
42 let g:tar_cmd= "tar"
|
|
43 endif
|
557
|
44 if !exists("g:tar_writeoptions")
|
|
45 let g:tar_writeoptions= "uf"
|
|
46 endif
|
1624
|
47
|
|
48 if !exists("g:netrw_cygwin")
|
|
49 if has("win32") || has("win95") || has("win64") || has("win16")
|
|
50 if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
|
|
51 let g:netrw_cygwin= 1
|
|
52 else
|
|
53 let g:netrw_cygwin= 0
|
|
54 endif
|
|
55 else
|
|
56 let g:netrw_cygwin= 0
|
|
57 endif
|
|
58 endif
|
|
59
|
|
60 " set up shell quoting character
|
1125
|
61 if !exists("g:tar_shq")
|
1624
|
62 if exists("&shq") && &shq != ""
|
|
63 let g:tar_shq= &shq
|
|
64 elseif has("win32") || has("win95") || has("win64") || has("win16")
|
|
65 if exists("g:netrw_cygwin") && g:netrw_cygwin
|
|
66 let g:tar_shq= "'"
|
|
67 else
|
|
68 let g:tar_shq= '"'
|
|
69 endif
|
|
70 else
|
1125
|
71 let g:tar_shq= "'"
|
|
72 endif
|
1624
|
73 " call Decho("g:tar_shq<".g:tar_shq.">")
|
1125
|
74 endif
|
557
|
75
|
|
76 " ----------------
|
|
77 " Functions: {{{1
|
|
78 " ----------------
|
446
|
79
|
527
|
80 " ---------------------------------------------------------------------
|
557
|
81 " tar#Browse: {{{2
|
|
82 fun! tar#Browse(tarfile)
|
|
83 " call Dfunc("tar#Browse(tarfile<".a:tarfile.">)")
|
569
|
84 let repkeep= &report
|
|
85 set report=10
|
446
|
86
|
557
|
87 " sanity checks
|
819
|
88 if !executable(g:tar_cmd)
|
1125
|
89 redraw!
|
819
|
90 echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
|
1125
|
91 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
569
|
92 let &report= repkeep
|
557
|
93 " call Dret("tar#Browse")
|
|
94 return
|
|
95 endif
|
|
96 if !filereadable(a:tarfile)
|
819
|
97 " call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
|
557
|
98 if a:tarfile !~# '^\a\+://'
|
|
99 " if its an url, don't complain, let url-handlers such as vim do its thing
|
1125
|
100 redraw!
|
557
|
101 echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
|
1125
|
102 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
557
|
103 endif
|
569
|
104 let &report= repkeep
|
557
|
105 " call Dret("tar#Browse : file<".a:tarfile."> not readable")
|
|
106 return
|
|
107 endif
|
|
108 if &ma != 1
|
|
109 set ma
|
|
110 endif
|
|
111 let w:tarfile= a:tarfile
|
446
|
112
|
557
|
113 setlocal noswapfile
|
|
114 setlocal buftype=nofile
|
|
115 setlocal bufhidden=hide
|
|
116 setlocal nobuflisted
|
|
117 setlocal nowrap
|
|
118 set ft=tar
|
446
|
119
|
557
|
120 " give header
|
819
|
121 " call Decho("printing header")
|
1624
|
122 let lastline= line("$")
|
|
123 call setline(lastline+1,'" tar.vim version '.g:loaded_tar)
|
|
124 call setline(lastline+2,'" Browsing tarfile '.a:tarfile)
|
|
125 call setline(lastline+3,'" Select a file with cursor and press ENTER')
|
|
126 $put =''
|
557
|
127 0d
|
|
128 $
|
446
|
129
|
819
|
130 let tarfile= a:tarfile
|
|
131 if has("win32") && executable("cygpath")
|
|
132 " assuming cygwin
|
1668
|
133 let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
|
819
|
134 endif
|
857
|
135 let curlast= line("$")
|
819
|
136 if tarfile =~# '\.\(gz\|tgz\)$'
|
1702
|
137 " call Decho("1: exe silent r! gzip -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
|
1668
|
138 exe "silent r! gzip -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
|
1624
|
139 elseif tarfile =~# '\.lrp'
|
1668
|
140 " call Decho("2: exe silent r! cat -- ".s:Escape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
|
|
141 exe "silent r! cat -- ".s:Escape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
|
819
|
142 elseif tarfile =~# '\.bz2$'
|
1702
|
143 " call Decho("3: exe silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
|
1668
|
144 exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
|
557
|
145 else
|
1702
|
146 if tarfile =~ '^\s*-'
|
|
147 " A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
|
|
148 let tarfile = substitute(tarfile, '-', './-', '')
|
|
149 endif
|
|
150 " call Decho("4: exe silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile,1))
|
1668
|
151 exe "silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile,1)
|
557
|
152 endif
|
819
|
153 if v:shell_error != 0
|
1125
|
154 redraw!
|
857
|
155 echohl WarningMsg | echo "***warning*** (tar#Browse) please check your g:tar_browseoptions<".g:tar_browseoptions.">"
|
1125
|
156 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
857
|
157 " call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
|
|
158 return
|
|
159 endif
|
1125
|
160 if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)')
|
|
161 redraw!
|
857
|
162 echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
|
1125
|
163 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
857
|
164 silent %d
|
|
165 let eikeep= &ei
|
|
166 set ei=BufReadCmd,FileReadCmd
|
1668
|
167 exe "r ".fnameescape(a:tarfile)
|
857
|
168 let &ei= eikeep
|
|
169 1d
|
|
170 " call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
|
819
|
171 return
|
|
172 endif
|
446
|
173
|
557
|
174 setlocal noma nomod ro
|
|
175 noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
|
|
176
|
569
|
177 let &report= repkeep
|
557
|
178 " call Dret("tar#Browse : w:tarfile<".w:tarfile.">")
|
527
|
179 endfun
|
|
180
|
|
181 " ---------------------------------------------------------------------
|
557
|
182 " TarBrowseSelect: {{{2
|
|
183 fun! s:TarBrowseSelect()
|
|
184 " call Dfunc("TarBrowseSelect() w:tarfile<".w:tarfile."> curfile<".expand("%").">")
|
569
|
185 let repkeep= &report
|
|
186 set report=10
|
557
|
187 let fname= getline(".")
|
|
188 " call Decho("fname<".fname.">")
|
|
189
|
1702
|
190 if !exists("g:tar_secure") && fname =~ '^\s*-\|\s\+-'
|
|
191 redraw!
|
|
192 echohl WarningMsg | echo '***error*** (tar#BrowseSelect) rejecting tarfile member<'.fname.'> because of embedded "-"; See :help tar-options'
|
|
193 " call Dret('tar#BrowseSelect : rejecting tarfile member<'.fname.'> because of embedded "-"')
|
|
194 return
|
|
195 endif
|
|
196
|
557
|
197 " sanity check
|
|
198 if fname =~ '^"'
|
569
|
199 let &report= repkeep
|
557
|
200 " call Dret("TarBrowseSelect")
|
|
201 return
|
|
202 endif
|
|
203
|
|
204 " about to make a new window, need to use w:tarfile
|
|
205 let tarfile= w:tarfile
|
|
206 let curfile= expand("%")
|
819
|
207 if has("win32") && executable("cygpath")
|
|
208 " assuming cygwin
|
1668
|
209 let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
|
819
|
210 endif
|
557
|
211
|
|
212 new
|
1624
|
213 if !exists("g:tar_nomax") || g:tar_nomax == 0
|
|
214 wincmd _
|
|
215 endif
|
557
|
216 let s:tblfile_{winnr()}= curfile
|
1624
|
217 call tar#Read("tarfile:".tarfile.'::'.fname,1)
|
557
|
218 filetype detect
|
|
219
|
569
|
220 let &report= repkeep
|
557
|
221 " call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
|
|
222 endfun
|
|
223
|
|
224 " ---------------------------------------------------------------------
|
|
225 " tar#Read: {{{2
|
|
226 fun! tar#Read(fname,mode)
|
|
227 " call Dfunc("tar#Read(fname<".a:fname.">,mode=".a:mode.")")
|
569
|
228 let repkeep= &report
|
|
229 set report=10
|
1624
|
230 let tarfile = substitute(a:fname,'tarfile:\(.\{-}\)::.*$','\1','')
|
|
231 let fname = substitute(a:fname,'tarfile:.\{-}::\(.*\)$','\1','')
|
819
|
232 if has("win32") && executable("cygpath")
|
|
233 " assuming cygwin
|
1668
|
234 let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
|
819
|
235 endif
|
|
236 " call Decho("tarfile<".tarfile.">")
|
|
237 " call Decho("fname<".fname.">")
|
557
|
238
|
1624
|
239 if fname =~ '\.gz$' && executable("zcat")
|
|
240 let decmp= "|zcat"
|
|
241 let doro = 1
|
|
242 elseif fname =~ '\.bz2$' && executable("bzcat")
|
|
243 let decmp= "|bzcat"
|
|
244 let doro = 1
|
|
245 else
|
|
246 let decmp=""
|
|
247 let doro = 0
|
|
248 if fname =~ '\.gz$\|\.bz2$\|\.Z$\|\.zip$'
|
|
249 setlocal bin
|
|
250 endif
|
|
251 endif
|
|
252
|
1702
|
253 if exists("g:tar_secure")
|
|
254 let tar_secure= " -- "
|
|
255 else
|
|
256 let tar_secure= " "
|
|
257 endif
|
557
|
258 if tarfile =~# '\.\(gz\|tgz\)$'
|
1702
|
259 " call Decho("5: exe silent r! gzip -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.s:Escape(fname,1))
|
|
260 exe "silent r! gzip -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
|
1624
|
261 elseif tarfile =~# '\.lrp$'
|
1702
|
262 " call Decho("6: exe silent r! cat ".s:Escape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp)
|
|
263 exe "silent r! cat -- ".s:Escape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
|
624
|
264 elseif tarfile =~# '\.bz2$'
|
1702
|
265 " call Decho("7: exe silent r! bzip2 -d -c ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp)
|
|
266 exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
|
557
|
267 else
|
1702
|
268 if tarfile =~ '^\s*-'
|
|
269 " A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
|
|
270 let tarfile = substitute(tarfile, '-', './-', '')
|
|
271 endif
|
|
272 " call Decho("8: exe silent r! ".g:tar_cmd." -".g:tar_readoptions." "s:Escape(tarfile,1).tar_secure..s:Escape(fname,1).decmp)
|
|
273 exe "silent r! ".g:tar_cmd." -".g:tar_readoptions." ".s:Escape(tarfile,1).tar_secure.s:Escape(fname,1).decmp
|
557
|
274 endif
|
1624
|
275
|
|
276 if doro
|
|
277 " because the reverse process of compressing changed files back into the tarball is not currently supported
|
|
278 setlocal ro
|
|
279 endif
|
|
280
|
557
|
281 let w:tarfile= a:fname
|
1668
|
282 exe "file tarfile::".fnameescape(fname)
|
557
|
283
|
|
284 " cleanup
|
|
285 0d
|
|
286 set nomod
|
|
287
|
569
|
288 let &report= repkeep
|
557
|
289 " call Dret("tar#Read : w:tarfile<".w:tarfile.">")
|
|
290 endfun
|
|
291
|
|
292 " ---------------------------------------------------------------------
|
|
293 " tar#Write: {{{2
|
|
294 fun! tar#Write(fname)
|
|
295 " call Dfunc("tar#Write(fname<".a:fname.">) w:tarfile<".w:tarfile."> tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
|
569
|
296 let repkeep= &report
|
|
297 set report=10
|
557
|
298
|
1702
|
299 if !exists("g:tar_secure") && a:fname =~ '^\s*-\|\s\+-'
|
|
300 redraw!
|
|
301 echohl WarningMsg | echo '***error*** (tar#Write) rejecting tarfile member<'.a:fname.'> because of embedded "-"; See :help tar-options'
|
|
302 " call Dret('tar#Write : rejecting tarfile member<'.fname.'> because of embedded "-"')
|
|
303 return
|
|
304 endif
|
|
305
|
527
|
306 " sanity checks
|
819
|
307 if !executable(g:tar_cmd)
|
1125
|
308 redraw!
|
819
|
309 echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
|
1125
|
310 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
569
|
311 let &report= repkeep
|
527
|
312 " call Dret("tar#Write")
|
|
313 return
|
|
314 endif
|
|
315 if !exists("*mkdir")
|
1125
|
316 redraw!
|
557
|
317 echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
|
1125
|
318 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
569
|
319 let &report= repkeep
|
527
|
320 " call Dret("tar#Write")
|
|
321 return
|
|
322 endif
|
|
323
|
|
324 let curdir= getcwd()
|
|
325 let tmpdir= tempname()
|
|
326 " call Decho("orig tempname<".tmpdir.">")
|
|
327 if tmpdir =~ '\.'
|
|
328 let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
|
|
329 endif
|
|
330 " call Decho("tmpdir<".tmpdir.">")
|
|
331 call mkdir(tmpdir,"p")
|
|
332
|
|
333 " attempt to change to the indicated directory
|
|
334 try
|
1624
|
335 exe "cd ".fnameescape(tmpdir)
|
527
|
336 catch /^Vim\%((\a\+)\)\=:E344/
|
1125
|
337 redraw!
|
557
|
338 echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
|
1125
|
339 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
569
|
340 let &report= repkeep
|
527
|
341 " call Dret("tar#Write")
|
|
342 return
|
|
343 endtry
|
|
344 " call Decho("current directory now: ".getcwd())
|
446
|
345
|
557
|
346 " place temporary files under .../_ZIPVIM_/
|
|
347 if isdirectory("_ZIPVIM_")
|
|
348 call s:Rmdir("_ZIPVIM_")
|
527
|
349 endif
|
557
|
350 call mkdir("_ZIPVIM_")
|
|
351 cd _ZIPVIM_
|
527
|
352 " call Decho("current directory now: ".getcwd())
|
|
353
|
1624
|
354 let tarfile = substitute(w:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
|
|
355 let fname = substitute(w:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
|
557
|
356
|
|
357 " handle compressed archives
|
|
358 if tarfile =~# '\.gz'
|
1668
|
359 call system("gzip -d -- ".s:Escape(tarfile,0))
|
557
|
360 let tarfile = substitute(tarfile,'\.gz','','e')
|
1702
|
361 let compress= "gzip -- ".s:Escape(tarfile,0)
|
|
362 " call Decho("compress<".compress.">")
|
557
|
363 elseif tarfile =~# '\.tgz'
|
1668
|
364 call system("gzip -d -- ".s:Escape(tarfile,0))
|
557
|
365 let tarfile = substitute(tarfile,'\.tgz','.tar','e')
|
1668
|
366 let compress= "gzip -- ".s:Escape(tarfile,0)
|
557
|
367 let tgz = 1
|
1702
|
368 " call Decho("compress<".compress.">")
|
557
|
369 elseif tarfile =~# '\.bz2'
|
1668
|
370 call system("bzip2 -d -- ".s:Escape(tarfile,0))
|
557
|
371 let tarfile = substitute(tarfile,'\.bz2','','e')
|
1668
|
372 let compress= "bzip2 -- ".s:Escape(tarfile,0)
|
1702
|
373 " call Decho("compress<".compress.">")
|
527
|
374 endif
|
1624
|
375 " call Decho("tarfile<".tarfile.">")
|
527
|
376
|
|
377 if v:shell_error != 0
|
1125
|
378 redraw!
|
557
|
379 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
|
1125
|
380 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
527
|
381 else
|
557
|
382
|
|
383 " call Decho("tarfile<".tarfile."> fname<".fname.">")
|
|
384
|
624
|
385 if fname =~ '/'
|
|
386 let dirpath = substitute(fname,'/[^/]\+$','','e')
|
|
387 if executable("cygpath")
|
1668
|
388 let dirpath = substitute(system("cygpath ".s:Escape(dirpath, 0)),'\n','','e')
|
624
|
389 endif
|
|
390 call mkdir(dirpath,"p")
|
|
391 endif
|
557
|
392 if tarfile !~ '/'
|
|
393 let tarfile= curdir.'/'.tarfile
|
|
394 endif
|
1702
|
395 if tarfile =~ '^\s*-'
|
|
396 " A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
|
|
397 let tarfile = substitute(tarfile, '-', './-', '')
|
|
398 endif
|
557
|
399 " call Decho("tarfile<".tarfile."> fname<".fname.">")
|
|
400
|
1702
|
401 if exists("g:tar_secure")
|
|
402 let tar_secure= " -- "
|
|
403 else
|
|
404 let tar_secure= " "
|
|
405 endif
|
1624
|
406 exe "w! ".fnameescape(fname)
|
557
|
407 if executable("cygpath")
|
1668
|
408 let tarfile = substitute(system("cygpath ".s:Escape(tarfile,0)),'\n','','e')
|
557
|
409 endif
|
|
410
|
|
411 " delete old file from tarfile
|
1702
|
412 " call Decho("system(".g:tar_cmd." --delete -f ".s:Escape(tarfile,0)." -- ".s:Escape(fname,0).")")
|
|
413 call system(g:tar_cmd." --delete -f ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
|
557
|
414 if v:shell_error != 0
|
1125
|
415 redraw!
|
1624
|
416 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
|
1125
|
417 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
557
|
418 else
|
|
419
|
|
420 " update tarfile with new file
|
1702
|
421 " call Decho(g:tar_cmd." -".g:tar_writeoptions." ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
|
|
422 call system(g:tar_cmd." -".g:tar_writeoptions." ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
|
557
|
423 if v:shell_error != 0
|
1125
|
424 redraw!
|
1624
|
425 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
|
1125
|
426 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
|
557
|
427 elseif exists("compress")
|
|
428 " call Decho("call system(".compress.")")
|
|
429 call system(compress)
|
|
430 if exists("tgz")
|
|
431 " call Decho("rename(".tarfile.".gz,".substitute(tarfile,'\.tar$','.tgz','e').")")
|
|
432 call rename(tarfile.".gz",substitute(tarfile,'\.tar$','.tgz','e'))
|
|
433 endif
|
|
434 endif
|
|
435 endif
|
|
436
|
|
437 " support writing tarfiles across a network
|
|
438 if s:tblfile_{winnr()} =~ '^\a\+://'
|
|
439 " call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
|
|
440 let tblfile= s:tblfile_{winnr()}
|
|
441 1split|enew
|
|
442 let binkeep= &binary
|
|
443 let eikeep = &ei
|
|
444 set binary ei=all
|
1668
|
445 exe "e! ".fnameescape(tarfile)
|
557
|
446 call netrw#NetWrite(tblfile)
|
|
447 let &ei = eikeep
|
|
448 let &binary = binkeep
|
|
449 q!
|
|
450 unlet s:tblfile_{winnr()}
|
|
451 endif
|
527
|
452 endif
|
|
453
|
|
454 " cleanup and restore current directory
|
|
455 cd ..
|
557
|
456 call s:Rmdir("_ZIPVIM_")
|
1668
|
457 exe "cd ".fnameescape(curdir)
|
527
|
458 setlocal nomod
|
|
459
|
569
|
460 let &report= repkeep
|
527
|
461 " call Dret("tar#Write")
|
|
462 endfun
|
|
463
|
|
464 " ---------------------------------------------------------------------
|
557
|
465 " Rmdir: {{{2
|
527
|
466 fun! s:Rmdir(fname)
|
|
467 " call Dfunc("Rmdir(fname<".a:fname.">)")
|
|
468 if has("unix")
|
1668
|
469 call system("/bin/rm -rf -- ".s:Escape(a:fname,0))
|
527
|
470 elseif has("win32") || has("win95") || has("win64") || has("win16")
|
|
471 if &shell =~? "sh$"
|
1668
|
472 call system("/bin/rm -rf -- ".s:Escape(a:fname,0))
|
527
|
473 else
|
1668
|
474 call system("del /S ".s:Escape(a:fname,0))
|
527
|
475 endif
|
|
476 endif
|
|
477 " call Dret("Rmdir")
|
|
478 endfun
|
|
479
|
1624
|
480 " ---------------------------------------------------------------------
|
|
481 " s:Escape: {{{2
|
1668
|
482 fun s:Escape(name,isfilt)
|
1624
|
483 " shellescape() was added by patch 7.0.111
|
|
484 if exists("*shellescape")
|
1668
|
485 if a:isfilt
|
|
486 let qnameq= shellescape(a:name,1)
|
|
487 else
|
|
488 let qnameq= shellescape(a:name)
|
|
489 endif
|
1624
|
490 else
|
|
491 let qnameq= g:tar_shq . a:name . g:tar_shq
|
|
492 endif
|
|
493 return qnameq
|
|
494 endfun
|
|
495
|
|
496 " ---------------------------------------------------------------------
|
557
|
497 " Modelines And Restoration: {{{1
|
|
498 let &cpo= s:keepcpo
|
|
499 unlet s:keepcpo
|
1624
|
500 " vim:ts=8 fdm=marker
|