blob: 6c172386c06f201fe758fb48aa422a776cd224b4 [file] [log] [blame]
Bram Moolenaara5792f52005-11-23 21:25:05 +00001" tar.vim: Handles browsing tarfiles
2" AUTOLOAD PORTION
Bram Moolenaarc81e5e72007-05-05 18:24:42 +00003" Date: Sep 29, 2006
4" Version: 11
5" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
Bram Moolenaara5792f52005-11-23 21:25:05 +00006" License: Vim License (see vim's :help license)
Bram Moolenaar87e25fd2005-07-27 21:13:01 +00007"
Bram Moolenaara5792f52005-11-23 21:25:05 +00008" Contains many ideas from Michael Toren's <tar.vim>
Bram Moolenaar87e25fd2005-07-27 21:13:01 +00009"
Bram Moolenaara5792f52005-11-23 21:25:05 +000010" Copyright: Copyright (C) 2005 Charles E. Campbell, Jr. {{{1
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,
14" tarPlugin.vim is provided *as is* and comes with no warranty
15" of any kind, either expressed or implied. By using this
16" plugin, you agree that in no event will the copyright
17" holder be liable for any damages resulting from the use
18" of this software.
Bram Moolenaar87e25fd2005-07-27 21:13:01 +000019
Bram Moolenaarab194812005-09-14 21:40:12 +000020" ---------------------------------------------------------------------
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000021" Load Once: {{{1
Bram Moolenaara5792f52005-11-23 21:25:05 +000022let s:keepcpo= &cpo
23set cpo&vim
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000024if &cp || exists("g:loaded_tar") || v:version < 700
Bram Moolenaara5792f52005-11-23 21:25:05 +000025 finish
26endif
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000027let g:loaded_tar= "v11"
Bram Moolenaar910f66f2006-04-05 20:41:53 +000028"call Decho("loading autoload/tar.vim")
Bram Moolenaar87e25fd2005-07-27 21:13:01 +000029
Bram Moolenaara5792f52005-11-23 21:25:05 +000030" ---------------------------------------------------------------------
31" Default Settings: {{{1
32if !exists("g:tar_browseoptions")
33 let g:tar_browseoptions= "Ptf"
34endif
35if !exists("g:tar_readoptions")
36 let g:tar_readoptions= "OPxf"
37endif
Bram Moolenaar910f66f2006-04-05 20:41:53 +000038if !exists("g:tar_cmd")
39 let g:tar_cmd= "tar"
40endif
Bram Moolenaara5792f52005-11-23 21:25:05 +000041if !exists("g:tar_writeoptions")
42 let g:tar_writeoptions= "uf"
43endif
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000044if !exists("g:tar_shq")
45 if has("unix")
46 let g:tar_shq= "'"
47 else
48 let g:tar_shq= '"'
49 endif
50endif
Bram Moolenaar87e25fd2005-07-27 21:13:01 +000051
Bram Moolenaara5792f52005-11-23 21:25:05 +000052" ----------------
53" Functions: {{{1
54" ----------------
Bram Moolenaar87e25fd2005-07-27 21:13:01 +000055
Bram Moolenaara5792f52005-11-23 21:25:05 +000056" ---------------------------------------------------------------------
57" tar#Browse: {{{2
58fun! tar#Browse(tarfile)
59" call Dfunc("tar#Browse(tarfile<".a:tarfile.">)")
Bram Moolenaarbba577a2005-11-28 23:05:55 +000060 let repkeep= &report
61 set report=10
Bram Moolenaar87e25fd2005-07-27 21:13:01 +000062
Bram Moolenaara5792f52005-11-23 21:25:05 +000063 " sanity checks
Bram Moolenaar910f66f2006-04-05 20:41:53 +000064 if !executable(g:tar_cmd)
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000065 redraw!
Bram Moolenaar910f66f2006-04-05 20:41:53 +000066 echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000067" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaarbba577a2005-11-28 23:05:55 +000068 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +000069" call Dret("tar#Browse")
70 return
71 endif
72 if !filereadable(a:tarfile)
Bram Moolenaar910f66f2006-04-05 20:41:53 +000073" call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
Bram Moolenaara5792f52005-11-23 21:25:05 +000074 if a:tarfile !~# '^\a\+://'
75 " if its an url, don't complain, let url-handlers such as vim do its thing
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000076 redraw!
Bram Moolenaara5792f52005-11-23 21:25:05 +000077 echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
Bram Moolenaarc81e5e72007-05-05 18:24:42 +000078" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaara5792f52005-11-23 21:25:05 +000079 endif
Bram Moolenaarbba577a2005-11-28 23:05:55 +000080 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +000081" call Dret("tar#Browse : file<".a:tarfile."> not readable")
82 return
83 endif
84 if &ma != 1
85 set ma
86 endif
87 let w:tarfile= a:tarfile
Bram Moolenaar87e25fd2005-07-27 21:13:01 +000088
Bram Moolenaara5792f52005-11-23 21:25:05 +000089 setlocal noswapfile
90 setlocal buftype=nofile
91 setlocal bufhidden=hide
92 setlocal nobuflisted
93 setlocal nowrap
94 set ft=tar
Bram Moolenaar87e25fd2005-07-27 21:13:01 +000095
Bram Moolenaara5792f52005-11-23 21:25:05 +000096 " give header
Bram Moolenaar910f66f2006-04-05 20:41:53 +000097" call Decho("printing header")
Bram Moolenaara5792f52005-11-23 21:25:05 +000098 exe "$put ='".'\"'." tar.vim version ".g:loaded_tar."'"
99 exe "$put ='".'\"'." Browsing tarfile ".a:tarfile."'"
100 exe "$put ='".'\"'." Select a file with cursor and press ENTER"."'"
101 0d
102 $
Bram Moolenaar87e25fd2005-07-27 21:13:01 +0000103
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000104 let tarfile= a:tarfile
105 if has("win32") && executable("cygpath")
106 " assuming cygwin
107 let tarfile=substitute(system("cygpath -u ".tarfile),'\n$','','e')
Bram Moolenaara5792f52005-11-23 21:25:05 +0000108 endif
Bram Moolenaard68071d2006-05-02 22:08:30 +0000109 let curlast= line("$")
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000110 if tarfile =~# '\.\(gz\|tgz\)$'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000111" call Decho("exe silent r! gzip -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -".g:tar_browseoptions." - ")
112 exe "silent r! gzip -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -".g:tar_browseoptions." - "
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000113 elseif tarfile =~# '\.bz2$'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000114" call Decho("exe silent r! bzip2 -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -".g:tar_browseoptions." - ")
115 exe "silent r! bzip2 -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -".g:tar_browseoptions." - "
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000116 else
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000117" call Decho("exe silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".g:tar_shq.tarfile.g:tar_shq)
118 exe "silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".g:tar_shq.tarfile.g:tar_shq
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000119 endif
120 if v:shell_error != 0
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000121 redraw!
Bram Moolenaard68071d2006-05-02 22:08:30 +0000122 echohl WarningMsg | echo "***warning*** (tar#Browse) please check your g:tar_browseoptions<".g:tar_browseoptions.">"
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000123" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaard68071d2006-05-02 22:08:30 +0000124" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
Bram Moolenaard68071d2006-05-02 22:08:30 +0000125 return
126 endif
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000127 if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)')
128 redraw!
Bram Moolenaard68071d2006-05-02 22:08:30 +0000129 echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000130" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaard68071d2006-05-02 22:08:30 +0000131 silent %d
132 let eikeep= &ei
133 set ei=BufReadCmd,FileReadCmd
134 exe "r ".a:tarfile
135 let &ei= eikeep
136 1d
137" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000138 return
139 endif
Bram Moolenaara5792f52005-11-23 21:25:05 +0000140
141 setlocal noma nomod ro
142 noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
143
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000144 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +0000145" call Dret("tar#Browse : w:tarfile<".w:tarfile.">")
Bram Moolenaarab194812005-09-14 21:40:12 +0000146endfun
Bram Moolenaar87e25fd2005-07-27 21:13:01 +0000147
Bram Moolenaarab194812005-09-14 21:40:12 +0000148" ---------------------------------------------------------------------
Bram Moolenaara5792f52005-11-23 21:25:05 +0000149" TarBrowseSelect: {{{2
150fun! s:TarBrowseSelect()
151" call Dfunc("TarBrowseSelect() w:tarfile<".w:tarfile."> curfile<".expand("%").">")
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000152 let repkeep= &report
153 set report=10
Bram Moolenaara5792f52005-11-23 21:25:05 +0000154 let fname= getline(".")
155" call Decho("fname<".fname.">")
156
157 " sanity check
158 if fname =~ '^"'
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000159 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +0000160" call Dret("TarBrowseSelect")
161 return
162 endif
163
164 " about to make a new window, need to use w:tarfile
165 let tarfile= w:tarfile
166 let curfile= expand("%")
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000167 if has("win32") && executable("cygpath")
168 " assuming cygwin
169 let tarfile=substitute(system("cygpath -u ".tarfile),'\n$','','e')
170 endif
Bram Moolenaara5792f52005-11-23 21:25:05 +0000171
172 new
173 wincmd _
174 let s:tblfile_{winnr()}= curfile
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000175 call tar#Read("tarfile:".tarfile.':'.fname,1)
Bram Moolenaara5792f52005-11-23 21:25:05 +0000176 filetype detect
177
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000178 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +0000179" call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
180endfun
181
182" ---------------------------------------------------------------------
183" tar#Read: {{{2
184fun! tar#Read(fname,mode)
185" call Dfunc("tar#Read(fname<".a:fname.">,mode=".a:mode.")")
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000186 let repkeep= &report
187 set report=10
Bram Moolenaara5792f52005-11-23 21:25:05 +0000188 let tarfile = substitute(a:fname,'tarfile:\(.\{-}\):.*$','\1','')
189 let fname = substitute(a:fname,'tarfile:.\{-}:\(.*\)$','\1','')
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000190 if has("win32") && executable("cygpath")
191 " assuming cygwin
192 let tarfile=substitute(system("cygpath -u ".tarfile),'\n$','','e')
193 endif
194" call Decho("tarfile<".tarfile.">")
195" call Decho("fname<".fname.">")
Bram Moolenaara5792f52005-11-23 21:25:05 +0000196
197 if tarfile =~# '\.\(gz\|tgz\)$'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000198" call Decho("exe silent r! gzip -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -OPxf - '".fname."'")
199 exe "silent r! gzip -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -".g:tar_readoptions." - '".fname."'"
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +0000200 elseif tarfile =~# '\.bz2$'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000201" call Decho("exe silent r! bzip2 -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -".g:tar_readoptions." - '".fname."'")
202 exe "silent r! bzip2 -d -c ".g:tar_shq.tarfile.g:tar_shq."| ".g:tar_cmd." -".g:tar_readoptions." - '".fname."'"
Bram Moolenaara5792f52005-11-23 21:25:05 +0000203 else
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000204" call Decho("exe silent r! ".g:tar_cmd." -".g:tar_readoptions." ".g:tar_shq.tarfile.g:tar_shq." ".g:tar_shq.fname.g:tar_shq)
205 exe "silent r! ".g:tar_cmd." -".g:tar_readoptions." ".g:tar_shq.tarfile.g:tar_shq." ".g:tar_shq.fname.g:tar_shq
Bram Moolenaara5792f52005-11-23 21:25:05 +0000206 endif
207 let w:tarfile= a:fname
208 exe "file tarfile:".fname
209
210 " cleanup
211 0d
212 set nomod
213
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000214 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +0000215" call Dret("tar#Read : w:tarfile<".w:tarfile.">")
216endfun
217
218" ---------------------------------------------------------------------
219" tar#Write: {{{2
220fun! tar#Write(fname)
221" call Dfunc("tar#Write(fname<".a:fname.">) w:tarfile<".w:tarfile."> tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000222 let repkeep= &report
223 set report=10
Bram Moolenaara5792f52005-11-23 21:25:05 +0000224
Bram Moolenaarab194812005-09-14 21:40:12 +0000225 " sanity checks
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000226 if !executable(g:tar_cmd)
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000227 redraw!
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000228 echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000229" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000230 let &report= repkeep
Bram Moolenaarab194812005-09-14 21:40:12 +0000231" call Dret("tar#Write")
232 return
233 endif
234 if !exists("*mkdir")
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000235 redraw!
Bram Moolenaara5792f52005-11-23 21:25:05 +0000236 echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000237" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000238 let &report= repkeep
Bram Moolenaarab194812005-09-14 21:40:12 +0000239" call Dret("tar#Write")
240 return
241 endif
242
243 let curdir= getcwd()
244 let tmpdir= tempname()
245" call Decho("orig tempname<".tmpdir.">")
246 if tmpdir =~ '\.'
247 let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
248 endif
249" call Decho("tmpdir<".tmpdir.">")
250 call mkdir(tmpdir,"p")
251
252 " attempt to change to the indicated directory
253 try
254 exe "cd ".escape(tmpdir,' \')
255 catch /^Vim\%((\a\+)\)\=:E344/
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000256 redraw!
Bram Moolenaara5792f52005-11-23 21:25:05 +0000257 echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000258" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000259 let &report= repkeep
Bram Moolenaarab194812005-09-14 21:40:12 +0000260" call Dret("tar#Write")
261 return
262 endtry
263" call Decho("current directory now: ".getcwd())
264
Bram Moolenaara5792f52005-11-23 21:25:05 +0000265 " place temporary files under .../_ZIPVIM_/
266 if isdirectory("_ZIPVIM_")
267 call s:Rmdir("_ZIPVIM_")
Bram Moolenaarab194812005-09-14 21:40:12 +0000268 endif
Bram Moolenaara5792f52005-11-23 21:25:05 +0000269 call mkdir("_ZIPVIM_")
270 cd _ZIPVIM_
Bram Moolenaarab194812005-09-14 21:40:12 +0000271" call Decho("current directory now: ".getcwd())
272
Bram Moolenaara5792f52005-11-23 21:25:05 +0000273 let tarfile = substitute(w:tarfile,'tarfile:\(.\{-}\):.*$','\1','')
274 let fname = substitute(w:tarfile,'tarfile:.\{-}:\(.*\)$','\1','')
275
276 " handle compressed archives
277 if tarfile =~# '\.gz'
278 call system("gzip -d ".tarfile)
279 let tarfile = substitute(tarfile,'\.gz','','e')
280 let compress= "gzip '".tarfile."'"
281 elseif tarfile =~# '\.tgz'
282 call system("gzip -d ".tarfile)
283 let tarfile = substitute(tarfile,'\.tgz','.tar','e')
284 let compress= "gzip '".tarfile."'"
285 let tgz = 1
286 elseif tarfile =~# '\.bz2'
287 call system("bzip2 -d ".tarfile)
288 let tarfile = substitute(tarfile,'\.bz2','','e')
289 let compress= "bzip2 '".tarfile."'"
Bram Moolenaarab194812005-09-14 21:40:12 +0000290 endif
291
Bram Moolenaarab194812005-09-14 21:40:12 +0000292 if v:shell_error != 0
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000293 redraw!
Bram Moolenaara5792f52005-11-23 21:25:05 +0000294 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000295" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaarab194812005-09-14 21:40:12 +0000296 else
Bram Moolenaara5792f52005-11-23 21:25:05 +0000297
298" call Decho("tarfile<".tarfile."> fname<".fname.">")
299
Bram Moolenaar1cbe5f72005-12-29 22:51:09 +0000300 if fname =~ '/'
301 let dirpath = substitute(fname,'/[^/]\+$','','e')
302 if executable("cygpath")
303 let dirpath = substitute(system("cygpath ".dirpath),'\n','','e')
304 endif
305 call mkdir(dirpath,"p")
306 endif
Bram Moolenaara5792f52005-11-23 21:25:05 +0000307 if tarfile !~ '/'
308 let tarfile= curdir.'/'.tarfile
309 endif
310" call Decho("tarfile<".tarfile."> fname<".fname.">")
311
Bram Moolenaara5792f52005-11-23 21:25:05 +0000312 exe "w! ".fname
313 if executable("cygpath")
Bram Moolenaara5792f52005-11-23 21:25:05 +0000314 let tarfile = substitute(system("cygpath ".tarfile),'\n','','e')
315 endif
316
317 " delete old file from tarfile
318" call Decho("tar --delete -f '".tarfile."' '".fname."'")
319 call system("tar --delete -f '".tarfile."' '".fname."'")
320 if v:shell_error != 0
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000321 redraw!
Bram Moolenaara5792f52005-11-23 21:25:05 +0000322 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000323" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaara5792f52005-11-23 21:25:05 +0000324 else
325
326 " update tarfile with new file
327" call Decho("tar -".g:tar_writeoptions." '".tarfile."' '".fname."'")
328 call system("tar -".g:tar_writeoptions." '".tarfile."' '".fname."'")
329 if v:shell_error != 0
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000330 redraw!
Bram Moolenaara5792f52005-11-23 21:25:05 +0000331 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000332" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaara5792f52005-11-23 21:25:05 +0000333 elseif exists("compress")
334" call Decho("call system(".compress.")")
335 call system(compress)
336 if exists("tgz")
337" call Decho("rename(".tarfile.".gz,".substitute(tarfile,'\.tar$','.tgz','e').")")
338 call rename(tarfile.".gz",substitute(tarfile,'\.tar$','.tgz','e'))
339 endif
340 endif
341 endif
342
343 " support writing tarfiles across a network
344 if s:tblfile_{winnr()} =~ '^\a\+://'
345" call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
346 let tblfile= s:tblfile_{winnr()}
347 1split|enew
348 let binkeep= &binary
349 let eikeep = &ei
350 set binary ei=all
351 exe "e! ".tarfile
352 call netrw#NetWrite(tblfile)
353 let &ei = eikeep
354 let &binary = binkeep
355 q!
356 unlet s:tblfile_{winnr()}
357 endif
Bram Moolenaarab194812005-09-14 21:40:12 +0000358 endif
359
360 " cleanup and restore current directory
361 cd ..
Bram Moolenaara5792f52005-11-23 21:25:05 +0000362 call s:Rmdir("_ZIPVIM_")
Bram Moolenaarab194812005-09-14 21:40:12 +0000363 exe "cd ".escape(curdir,' \')
364 setlocal nomod
365
Bram Moolenaarbba577a2005-11-28 23:05:55 +0000366 let &report= repkeep
Bram Moolenaarab194812005-09-14 21:40:12 +0000367" call Dret("tar#Write")
368endfun
369
370" ---------------------------------------------------------------------
Bram Moolenaara5792f52005-11-23 21:25:05 +0000371" Rmdir: {{{2
Bram Moolenaarab194812005-09-14 21:40:12 +0000372fun! s:Rmdir(fname)
373" call Dfunc("Rmdir(fname<".a:fname.">)")
374 if has("unix")
375 call system("/bin/rm -rf ".a:fname)
376 elseif has("win32") || has("win95") || has("win64") || has("win16")
377 if &shell =~? "sh$"
378 call system("/bin/rm -rf ".a:fname)
379 else
380 call system("del /S ".a:fname)
381 endif
382 endif
383" call Dret("Rmdir")
384endfun
385
Bram Moolenaara5792f52005-11-23 21:25:05 +0000386" ------------------------------------------------------------------------
387" Modelines And Restoration: {{{1
388let &cpo= s:keepcpo
389unlet s:keepcpo
Bram Moolenaarc81e5e72007-05-05 18:24:42 +0000390" vim:ts=8 fdm=marker