blob: b7a5bffbf19724e9437577a42f14c97fe6c7b8b7 [file] [log] [blame]
Bram Moolenaar60a795a2005-09-16 21:55:43 +00001" zip.vim: Handles browsing zipfiles
2" AUTOLOAD PORTION
Bram Moolenaarff034192013-04-24 18:51:19 +02003" Date: Apr 17, 2013
4" Version: 26
5" Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
Bram Moolenaar9964e462007-05-05 17:54:07 +00006" License: Vim License (see vim's :help license)
Bram Moolenaarff034192013-04-24 18:51:19 +02007" Copyright: Copyright (C) 2005-2012 Charles E. Campbell {{{1
Bram Moolenaar60a795a2005-09-16 21:55:43 +00008" Permission is hereby granted to use and distribute this code,
9" with or without modifications, provided that this copyright
10" notice is copied with it. Like anything else that's free,
Bram Moolenaar446cb832008-06-24 21:56:24 +000011" zip.vim and zipPlugin.vim are provided *as is* and comes with
12" no warranty of any kind, either expressed or implied. By using
13" this plugin, you agree that in no event will the copyright
Bram Moolenaar60a795a2005-09-16 21:55:43 +000014" holder be liable for any damages resulting from the use
15" of this software.
16
17" ---------------------------------------------------------------------
Bram Moolenaar9964e462007-05-05 17:54:07 +000018" Load Once: {{{1
Bram Moolenaar00a927d2010-05-14 23:24:24 +020019if &cp || exists("g:loaded_zip")
Bram Moolenaar60a795a2005-09-16 21:55:43 +000020 finish
21endif
Bram Moolenaarff034192013-04-24 18:51:19 +020022let g:loaded_zip= "v26"
Bram Moolenaar00a927d2010-05-14 23:24:24 +020023if v:version < 702
24 echohl WarningMsg
25 echo "***warning*** this version of zip needs vim 7.2"
26 echohl Normal
27 finish
28endif
29let s:keepcpo= &cpo
30set cpo&vim
Bram Moolenaar60a795a2005-09-16 21:55:43 +000031
Bram Moolenaardb552d602006-03-23 22:59:57 +000032let s:zipfile_escape = ' ?&;\'
Bram Moolenaar9964e462007-05-05 17:54:07 +000033let s:ERROR = 2
34let s:WARNING = 1
35let s:NOTE = 0
36
37" ---------------------------------------------------------------------
38" Global Values: {{{1
39if !exists("g:zip_shq")
Bram Moolenaar446cb832008-06-24 21:56:24 +000040 if &shq != ""
41 let g:zip_shq= &shq
42 elseif has("unix")
Bram Moolenaar9964e462007-05-05 17:54:07 +000043 let g:zip_shq= "'"
44 else
45 let g:zip_shq= '"'
46 endif
47endif
Bram Moolenaarccc18222007-05-10 18:25:20 +000048if !exists("g:zip_zipcmd")
49 let g:zip_zipcmd= "zip"
50endif
51if !exists("g:zip_unzipcmd")
52 let g:zip_unzipcmd= "unzip"
53endif
Bram Moolenaar60a795a2005-09-16 21:55:43 +000054
55" ----------------
56" Functions: {{{1
57" ----------------
58
59" ---------------------------------------------------------------------
60" zip#Browse: {{{2
61fun! zip#Browse(zipfile)
62" call Dfunc("zip#Browse(zipfile<".a:zipfile.">)")
Bram Moolenaar36c31f72005-11-28 23:01:53 +000063 let repkeep= &report
64 set report=10
Bram Moolenaar60a795a2005-09-16 21:55:43 +000065
66 " sanity checks
Bram Moolenaare37d50a2008-08-06 17:06:04 +000067 if !exists("*fnameescape")
68 if &verbose > 1
69 echoerr "the zip plugin is not available (your vim doens't support fnameescape())"
70 endif
71 return
72 endif
Bram Moolenaarccc18222007-05-10 18:25:20 +000073 if !executable(g:zip_unzipcmd)
Bram Moolenaar9964e462007-05-05 17:54:07 +000074 redraw!
Bram Moolenaar60a795a2005-09-16 21:55:43 +000075 echohl Error | echo "***error*** (zip#Browse) unzip not available on your system"
Bram Moolenaar9964e462007-05-05 17:54:07 +000076" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaar36c31f72005-11-28 23:01:53 +000077 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +000078" call Dret("zip#Browse")
79 return
80 endif
81 if !filereadable(a:zipfile)
Bram Moolenaara5792f52005-11-23 21:25:05 +000082 if a:zipfile !~# '^\a\+://'
83 " if its an url, don't complain, let url-handlers such as vim do its thing
Bram Moolenaar9964e462007-05-05 17:54:07 +000084 redraw!
Bram Moolenaara5792f52005-11-23 21:25:05 +000085 echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
Bram Moolenaar9964e462007-05-05 17:54:07 +000086" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaara5792f52005-11-23 21:25:05 +000087 endif
Bram Moolenaar36c31f72005-11-28 23:01:53 +000088 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +000089" call Dret("zip#Browse : file<".a:zipfile."> not readable")
Bram Moolenaar60a795a2005-09-16 21:55:43 +000090 return
91 endif
Bram Moolenaardb552d602006-03-23 22:59:57 +000092" call Decho("passed sanity checks")
Bram Moolenaar60a795a2005-09-16 21:55:43 +000093 if &ma != 1
94 set ma
95 endif
Bram Moolenaarccc18222007-05-10 18:25:20 +000096 let b:zipfile= a:zipfile
Bram Moolenaar60a795a2005-09-16 21:55:43 +000097
98 setlocal noswapfile
99 setlocal buftype=nofile
100 setlocal bufhidden=hide
101 setlocal nobuflisted
102 setlocal nowrap
103 set ft=tar
104
105 " give header
Bram Moolenaar251e1912011-06-19 05:09:16 +0200106 call append(0, ['" zip.vim version '.g:loaded_zip,
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100107 \ '" Browsing zipfile '.a:zipfile,
108 \ '" Select a file with cursor and press ENTER'])
Bram Moolenaar251e1912011-06-19 05:09:16 +0200109 keepj $
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000110
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000111" call Decho("exe silent r! ".g:zip_unzipcmd." -l -- ".s:Escape(a:zipfile,1))
Bram Moolenaar6be7f872012-01-20 21:08:56 +0100112 exe "keepj sil! r! ".g:zip_unzipcmd." -Z -1 -- ".s:Escape(a:zipfile,1)
Bram Moolenaard68071d2006-05-02 22:08:30 +0000113 if v:shell_error != 0
Bram Moolenaar9964e462007-05-05 17:54:07 +0000114 redraw!
Bram Moolenaarc236c162008-07-13 17:41:49 +0000115 echohl WarningMsg | echo "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None
Bram Moolenaar9964e462007-05-05 17:54:07 +0000116" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaar251e1912011-06-19 05:09:16 +0200117 keepj sil! %d
Bram Moolenaard68071d2006-05-02 22:08:30 +0000118 let eikeep= &ei
119 set ei=BufReadCmd,FileReadCmd
Bram Moolenaar251e1912011-06-19 05:09:16 +0200120 exe "keepj r ".fnameescape(a:zipfile)
Bram Moolenaard68071d2006-05-02 22:08:30 +0000121 let &ei= eikeep
Bram Moolenaar251e1912011-06-19 05:09:16 +0200122 keepj 1d
Bram Moolenaard68071d2006-05-02 22:08:30 +0000123" call Dret("zip#Browse")
124 return
125 endif
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000126
127 setlocal noma nomod ro
128 noremap <silent> <buffer> <cr> :call <SID>ZipBrowseSelect()<cr>
129
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000130 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000131" call Dret("zip#Browse")
132endfun
133
134" ---------------------------------------------------------------------
135" ZipBrowseSelect: {{{2
136fun! s:ZipBrowseSelect()
Bram Moolenaarccc18222007-05-10 18:25:20 +0000137" call Dfunc("ZipBrowseSelect() zipfile<".b:zipfile."> curfile<".expand("%").">")
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000138 let repkeep= &report
139 set report=10
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000140 let fname= getline(".")
141
142 " sanity check
143 if fname =~ '^"'
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000144 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000145" call Dret("ZipBrowseSelect")
146 return
147 endif
148 if fname =~ '/$'
Bram Moolenaar9964e462007-05-05 17:54:07 +0000149 redraw!
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000150 echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None
Bram Moolenaar9964e462007-05-05 17:54:07 +0000151" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000152 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000153" call Dret("ZipBrowseSelect")
154 return
155 endif
156
157" call Decho("fname<".fname.">")
158
159 " get zipfile to the new-window
Bram Moolenaarccc18222007-05-10 18:25:20 +0000160 let zipfile = b:zipfile
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000161 let curfile= expand("%")
Bram Moolenaardb552d602006-03-23 22:59:57 +0000162" call Decho("zipfile<".zipfile.">")
163" call Decho("curfile<".curfile.">")
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000164
165 new
Bram Moolenaar446cb832008-06-24 21:56:24 +0000166 if !exists("g:zip_nomax") || g:zip_nomax == 0
167 wincmd _
168 endif
Bram Moolenaara5792f52005-11-23 21:25:05 +0000169 let s:zipfile_{winnr()}= curfile
Bram Moolenaarc236c162008-07-13 17:41:49 +0000170" call Decho("exe e ".fnameescape("zipfile:".zipfile.'::'.fname))
171 exe "e ".fnameescape("zipfile:".zipfile.'::'.fname)
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000172 filetype detect
173
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000174 let &report= repkeep
Bram Moolenaara5792f52005-11-23 21:25:05 +0000175" call Dret("ZipBrowseSelect : s:zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000176endfun
177
178" ---------------------------------------------------------------------
179" zip#Read: {{{2
180fun! zip#Read(fname,mode)
181" call Dfunc("zip#Read(fname<".a:fname.">,mode=".a:mode.")")
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000182 let repkeep= &report
183 set report=10
184
Bram Moolenaard68071d2006-05-02 22:08:30 +0000185 if has("unix")
186 let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
187 let fname = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
188 else
189 let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
190 let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
Bram Moolenaarff034192013-04-24 18:51:19 +0200191 let fname = substitute(fname, '[', '[[]', 'g')
Bram Moolenaard68071d2006-05-02 22:08:30 +0000192 endif
193" call Decho("zipfile<".zipfile.">")
194" call Decho("fname <".fname.">")
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000195
Bram Moolenaarff034192013-04-24 18:51:19 +0200196 " the following code does much the same thing as
197 " exe "keepj sil! r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1)
198 " but allows zipfile:... entries in quickfix lists
199 let temp = tempname()
200 let fn = expand('%:p')
201 exe "sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp
202" call Decho("exe sil! !".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fnameescape(fname),1).' > '.temp)
203 sil exe 'keepalt file '.temp
204 sil keepj e!
205 sil exe 'keepalt file '.fnameescape(fn)
206 call delete(temp)
207
Bram Moolenaar251e1912011-06-19 05:09:16 +0200208 filetype detect
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000209
210 " cleanup
Bram Moolenaar251e1912011-06-19 05:09:16 +0200211 keepj 0d
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000212 set nomod
213
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000214 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000215" call Dret("zip#Read")
216endfun
217
218" ---------------------------------------------------------------------
219" zip#Write: {{{2
220fun! zip#Write(fname)
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000221" call Dfunc("zip#Write(fname<".a:fname.">) zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000222 let repkeep= &report
223 set report=10
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000224
225 " sanity checks
Bram Moolenaarccc18222007-05-10 18:25:20 +0000226 if !executable(g:zip_zipcmd)
Bram Moolenaar9964e462007-05-05 17:54:07 +0000227 redraw!
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000228 echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the zip pgm" | echohl None
Bram Moolenaar9964e462007-05-05 17:54:07 +0000229" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000230 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000231" call Dret("zip#Write")
232 return
233 endif
234 if !exists("*mkdir")
Bram Moolenaar9964e462007-05-05 17:54:07 +0000235 redraw!
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000236 echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None
Bram Moolenaar9964e462007-05-05 17:54:07 +0000237" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000238 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000239" call Dret("zip#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
Bram Moolenaar9964e462007-05-05 17:54:07 +0000253 if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory")
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000254 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000255" call Dret("zip#Write")
256 return
Bram Moolenaar9964e462007-05-05 17:54:07 +0000257 endif
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000258" call Decho("current directory now: ".getcwd())
259
260 " place temporary files under .../_ZIPVIM_/
261 if isdirectory("_ZIPVIM_")
262 call s:Rmdir("_ZIPVIM_")
263 endif
264 call mkdir("_ZIPVIM_")
265 cd _ZIPVIM_
266" call Decho("current directory now: ".getcwd())
267
Bram Moolenaard68071d2006-05-02 22:08:30 +0000268 if has("unix")
269 let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
270 let fname = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
271 else
272 let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
273 let fname = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
274 endif
275" call Decho("zipfile<".zipfile.">")
276" call Decho("fname <".fname.">")
Bram Moolenaarc7486e02005-12-29 22:48:26 +0000277
278 if fname =~ '/'
279 let dirpath = substitute(fname,'/[^/]\+$','','e')
Bram Moolenaarff034192013-04-24 18:51:19 +0200280 if has("win32unix") && executable("cygpath")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000281 let dirpath = substitute(system("cygpath ".s:Escape(dirpath,0)),'\n','','e')
Bram Moolenaarc7486e02005-12-29 22:48:26 +0000282 endif
Bram Moolenaar910f66f2006-04-05 20:41:53 +0000283" call Decho("mkdir(dirpath<".dirpath.">,p)")
Bram Moolenaarc7486e02005-12-29 22:48:26 +0000284 call mkdir(dirpath,"p")
285 endif
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000286 if zipfile !~ '/'
287 let zipfile= curdir.'/'.zipfile
288 endif
289" call Decho("zipfile<".zipfile."> fname<".fname.">")
290
Bram Moolenaarc236c162008-07-13 17:41:49 +0000291 exe "w! ".fnameescape(fname)
Bram Moolenaarff034192013-04-24 18:51:19 +0200292 if has("win32unix") && executable("cygpath")
Bram Moolenaarc236c162008-07-13 17:41:49 +0000293 let zipfile = substitute(system("cygpath ".s:Escape(zipfile,0)),'\n','','e')
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000294 endif
295
Bram Moolenaar9964e462007-05-05 17:54:07 +0000296 if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
297 let fname = substitute(fname, '[', '[[]', 'g')
298 endif
299
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000300" call Decho(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
301 call system(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000302 if v:shell_error != 0
Bram Moolenaar9964e462007-05-05 17:54:07 +0000303 redraw!
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000304 echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None
Bram Moolenaar9964e462007-05-05 17:54:07 +0000305" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Bram Moolenaara5792f52005-11-23 21:25:05 +0000306
307 elseif s:zipfile_{winnr()} =~ '^\a\+://'
308 " support writing zipfiles across a network
309 let netzipfile= s:zipfile_{winnr()}
Bram Moolenaar9964e462007-05-05 17:54:07 +0000310" call Decho("handle writing <".zipfile."> across network as <".netzipfile.">")
Bram Moolenaara5792f52005-11-23 21:25:05 +0000311 1split|enew
312 let binkeep= &binary
313 let eikeep = &ei
314 set binary ei=all
Bram Moolenaarc236c162008-07-13 17:41:49 +0000315 exe "e! ".fnameescape(zipfile)
Bram Moolenaara5792f52005-11-23 21:25:05 +0000316 call netrw#NetWrite(netzipfile)
317 let &ei = eikeep
318 let &binary = binkeep
319 q!
320 unlet s:zipfile_{winnr()}
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000321 endif
322
323 " cleanup and restore current directory
324 cd ..
325 call s:Rmdir("_ZIPVIM_")
Bram Moolenaar9964e462007-05-05 17:54:07 +0000326 call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!")
327 call s:Rmdir(tmpdir)
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000328 setlocal nomod
329
Bram Moolenaar36c31f72005-11-28 23:01:53 +0000330 let &report= repkeep
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000331" call Dret("zip#Write")
332endfun
333
334" ---------------------------------------------------------------------
Bram Moolenaarc236c162008-07-13 17:41:49 +0000335" s:Escape: {{{2
336fun! s:Escape(fname,isfilt)
337" call Dfunc("QuoteFileDir(fname<".a:fname."> isfilt=".a:isfilt.")")
338 if exists("*shellescape")
339 if a:isfilt
340 let qnameq= shellescape(a:fname,1)
341 else
342 let qnameq= shellescape(a:fname)
343 endif
Bram Moolenaar446cb832008-06-24 21:56:24 +0000344 else
345 let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq
346 endif
347" call Dret("QuoteFileDir <".qnameq.">")
348 return qnameq
Bram Moolenaar9964e462007-05-05 17:54:07 +0000349endfun
350
351" ---------------------------------------------------------------------
352" ChgDir: {{{2
353fun! s:ChgDir(newdir,errlvl,errmsg)
354" call Dfunc("ChgDir(newdir<".a:newdir."> errlvl=".a:errlvl." errmsg<".a:errmsg.">)")
355
Bram Moolenaar9964e462007-05-05 17:54:07 +0000356 try
Bram Moolenaare37d50a2008-08-06 17:06:04 +0000357 exe "cd ".fnameescape(a:newdir)
Bram Moolenaar9964e462007-05-05 17:54:07 +0000358 catch /^Vim\%((\a\+)\)\=:E344/
359 redraw!
360 if a:errlvl == s:NOTE
361 echo "***note*** ".a:errmsg
362 elseif a:errlvl == s:WARNING
363 echohl WarningMsg | echo "***warning*** ".a:errmsg | echohl NONE
364 elseif a:errlvl == s:ERROR
365 echohl Error | echo "***error*** ".a:errmsg | echohl NONE
366 endif
367" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
368" call Dret("ChgDir 1")
369 return 1
370 endtry
371
372" call Dret("ChgDir 0")
373 return 0
374endfun
375
376" ---------------------------------------------------------------------
Bram Moolenaarc236c162008-07-13 17:41:49 +0000377" s:Rmdir: {{{2
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000378fun! s:Rmdir(fname)
379" call Dfunc("Rmdir(fname<".a:fname.">)")
Bram Moolenaar9964e462007-05-05 17:54:07 +0000380 if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
Bram Moolenaarc236c162008-07-13 17:41:49 +0000381 call system("rmdir /S/Q ".s:Escape(a:fname,0))
Bram Moolenaar9964e462007-05-05 17:54:07 +0000382 else
Bram Moolenaarc236c162008-07-13 17:41:49 +0000383 call system("/bin/rm -rf ".s:Escape(a:fname,0))
Bram Moolenaar60a795a2005-09-16 21:55:43 +0000384 endif
385" call Dret("Rmdir")
386endfun
387
388" ------------------------------------------------------------------------
389" Modelines And Restoration: {{{1
390let &cpo= s:keepcpo
391unlet s:keepcpo
Bram Moolenaarccc18222007-05-10 18:25:20 +0000392" vim:ts=8 fdm=marker