0
0
mirror of https://github.com/vim/vim.git synced 2025-07-04 23:07:33 -04:00
vim/runtime/autoload/tar.vim

459 lines
15 KiB
VimL
Raw Normal View History

2005-11-23 21:25:05 +00:00
" tar.vim: Handles browsing tarfiles
" AUTOLOAD PORTION
2008-06-24 22:58:06 +00:00
" Date: Jun 12, 2008
" Version: 16
2007-05-05 18:24:42 +00:00
" Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
2005-11-23 21:25:05 +00:00
" License: Vim License (see vim's :help license)
2005-07-27 21:13:01 +00:00
"
2005-11-23 21:25:05 +00:00
" Contains many ideas from Michael Toren's <tar.vim>
2005-07-27 21:13:01 +00:00
"
2008-06-24 22:58:06 +00:00
" Copyright: Copyright (C) 2005-2008 Charles E. Campbell, Jr. {{{1
2005-11-23 21:25:05 +00:00
" Permission is hereby granted to use and distribute this code,
" with or without modifications, provided that this copyright
" notice is copied with it. Like anything else that's free,
2008-06-24 22:58:06 +00:00
" tar.vim and tarPlugin.vim are provided *as is* and comes
" with no warranty of any kind, either expressed or implied.
" By using this plugin, you agree that in no event will the
" copyright holder be liable for any damages resulting from
" the use of this software.
2005-11-23 21:25:05 +00:00
" ---------------------------------------------------------------------
2007-05-05 18:24:42 +00:00
" Load Once: {{{1
2005-11-23 21:25:05 +00:00
let s:keepcpo= &cpo
set cpo&vim
2007-05-05 18:24:42 +00:00
if &cp || exists("g:loaded_tar") || v:version < 700
2005-09-14 21:40:12 +00:00
finish
endif
2008-06-24 22:58:06 +00:00
let g:loaded_tar= "v16"
2006-04-05 20:41:53 +00:00
"call Decho("loading autoload/tar.vim")
2008-06-24 22:58:06 +00:00
if v:version < 701 || (v:version == 701 && !has("patch299"))
echoerr "(autoload/tar.vim) need vim v7.1 with patchlevel 299"
endif
2005-09-14 21:40:12 +00:00
" ---------------------------------------------------------------------
2005-11-23 21:25:05 +00:00
" Default Settings: {{{1
if !exists("g:tar_browseoptions")
let g:tar_browseoptions= "Ptf"
endif
if !exists("g:tar_readoptions")
let g:tar_readoptions= "OPxf"
endif
2006-04-05 20:41:53 +00:00
if !exists("g:tar_cmd")
let g:tar_cmd= "tar"
endif
2005-11-23 21:25:05 +00:00
if !exists("g:tar_writeoptions")
let g:tar_writeoptions= "uf"
endif
2008-06-24 22:58:06 +00:00
if !exists("g:netrw_cygwin")
if has("win32") || has("win95") || has("win64") || has("win16")
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
let g:netrw_cygwin= 1
else
let g:netrw_cygwin= 0
endif
else
let g:netrw_cygwin= 0
endif
endif
" set up shell quoting character
2007-05-05 18:24:42 +00:00
if !exists("g:tar_shq")
2008-06-24 22:58:06 +00:00
if exists("&shq") && &shq != ""
let g:tar_shq= &shq
elseif has("win32") || has("win95") || has("win64") || has("win16")
if exists("g:netrw_cygwin") && g:netrw_cygwin
let g:tar_shq= "'"
else
let g:tar_shq= '"'
endif
2007-05-05 18:24:42 +00:00
else
2008-06-24 22:58:06 +00:00
let g:tar_shq= "'"
2007-05-05 18:24:42 +00:00
endif
2008-06-24 22:58:06 +00:00
" call Decho("g:tar_shq<".g:tar_shq.">")
2007-05-05 18:24:42 +00:00
endif
2005-07-27 21:13:01 +00:00
2005-11-23 21:25:05 +00:00
" ----------------
" Functions: {{{1
" ----------------
2005-07-27 21:13:01 +00:00
2005-11-23 21:25:05 +00:00
" ---------------------------------------------------------------------
" tar#Browse: {{{2
fun! tar#Browse(tarfile)
" call Dfunc("tar#Browse(tarfile<".a:tarfile.">)")
2005-11-28 23:05:55 +00:00
let repkeep= &report
set report=10
2005-11-23 21:25:05 +00:00
" sanity checks
2006-04-05 20:41:53 +00:00
if !executable(g:tar_cmd)
2007-05-05 18:24:42 +00:00
redraw!
2006-04-05 20:41:53 +00:00
echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-11-23 21:25:05 +00:00
" call Dret("tar#Browse")
return
endif
if !filereadable(a:tarfile)
2006-04-05 20:41:53 +00:00
" call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
2005-11-23 21:25:05 +00:00
if a:tarfile !~# '^\a\+://'
" if its an url, don't complain, let url-handlers such as vim do its thing
2007-05-05 18:24:42 +00:00
redraw!
2005-11-23 21:25:05 +00:00
echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-11-23 21:25:05 +00:00
endif
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-11-23 21:25:05 +00:00
" call Dret("tar#Browse : file<".a:tarfile."> not readable")
return
endif
if &ma != 1
set ma
endif
let w:tarfile= a:tarfile
setlocal noswapfile
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal nobuflisted
setlocal nowrap
set ft=tar
" give header
2006-04-05 20:41:53 +00:00
" call Decho("printing header")
2008-06-24 22:58:06 +00:00
let lastline= line("$")
call setline(lastline+1,'" tar.vim version '.g:loaded_tar)
call setline(lastline+2,'" Browsing tarfile '.a:tarfile)
call setline(lastline+3,'" Select a file with cursor and press ENTER')
$put =''
2005-11-23 21:25:05 +00:00
0d
$
2006-04-05 20:41:53 +00:00
let tarfile= a:tarfile
if has("win32") && executable("cygpath")
" assuming cygwin
2008-06-24 22:58:06 +00:00
let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile)),'\n$','','e')
2006-04-05 20:41:53 +00:00
endif
2006-05-02 22:08:30 +00:00
let curlast= line("$")
2006-04-05 20:41:53 +00:00
if tarfile =~# '\.\(gz\|tgz\)$'
2008-06-24 22:58:06 +00:00
" call Decho("1: exe silent r! gzip -d -c ".s:Escape(tarfile)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "silent r! gzip -d -c -- ".s:Escape(tarfile)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
elseif tarfile =~# '\.lrp'
" call Decho("2: exe silent r! cat -- ".s:Escape(tarfile)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "silent r! cat -- ".s:Escape(tarfile)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
2006-04-05 20:41:53 +00:00
elseif tarfile =~# '\.bz2$'
2008-06-24 22:58:06 +00:00
" call Decho("3: exe silent r! bzip2 -d -c ".s:Escape(tarfile)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
2005-11-23 21:25:05 +00:00
else
2008-06-24 22:58:06 +00:00
" call Decho("4: exe silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile))
exe "silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile)
2006-04-05 20:41:53 +00:00
endif
if v:shell_error != 0
2007-05-05 18:24:42 +00:00
redraw!
2006-05-02 22:08:30 +00:00
echohl WarningMsg | echo "***warning*** (tar#Browse) please check your g:tar_browseoptions<".g:tar_browseoptions.">"
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2006-05-02 22:08:30 +00:00
" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
return
endif
2007-05-05 18:24:42 +00:00
if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)')
redraw!
2006-05-02 22:08:30 +00:00
echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2006-05-02 22:08:30 +00:00
silent %d
let eikeep= &ei
set ei=BufReadCmd,FileReadCmd
exe "r ".a:tarfile
let &ei= eikeep
1d
" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
2006-04-05 20:41:53 +00:00
return
2005-11-23 21:25:05 +00:00
endif
setlocal noma nomod ro
noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-11-23 21:25:05 +00:00
" call Dret("tar#Browse : w:tarfile<".w:tarfile.">")
2005-09-14 21:40:12 +00:00
endfun
2005-07-27 21:13:01 +00:00
2005-09-14 21:40:12 +00:00
" ---------------------------------------------------------------------
2005-11-23 21:25:05 +00:00
" TarBrowseSelect: {{{2
fun! s:TarBrowseSelect()
" call Dfunc("TarBrowseSelect() w:tarfile<".w:tarfile."> curfile<".expand("%").">")
2005-11-28 23:05:55 +00:00
let repkeep= &report
set report=10
2005-11-23 21:25:05 +00:00
let fname= getline(".")
" call Decho("fname<".fname.">")
" sanity check
if fname =~ '^"'
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-11-23 21:25:05 +00:00
" call Dret("TarBrowseSelect")
return
endif
" about to make a new window, need to use w:tarfile
let tarfile= w:tarfile
let curfile= expand("%")
2006-04-05 20:41:53 +00:00
if has("win32") && executable("cygpath")
" assuming cygwin
2008-06-24 22:58:06 +00:00
let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile)),'\n$','','e')
2006-04-05 20:41:53 +00:00
endif
2005-11-23 21:25:05 +00:00
new
2008-06-24 22:58:06 +00:00
if !exists("g:tar_nomax") || g:tar_nomax == 0
wincmd _
endif
2005-11-23 21:25:05 +00:00
let s:tblfile_{winnr()}= curfile
2008-06-24 22:58:06 +00:00
call tar#Read("tarfile:".tarfile.'::'.fname,1)
2005-11-23 21:25:05 +00:00
filetype detect
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-11-23 21:25:05 +00:00
" call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
endfun
" ---------------------------------------------------------------------
" tar#Read: {{{2
fun! tar#Read(fname,mode)
" call Dfunc("tar#Read(fname<".a:fname.">,mode=".a:mode.")")
2005-11-28 23:05:55 +00:00
let repkeep= &report
set report=10
2008-06-24 22:58:06 +00:00
let tarfile = substitute(a:fname,'tarfile:\(.\{-}\)::.*$','\1','')
let fname = substitute(a:fname,'tarfile:.\{-}::\(.*\)$','\1','')
2006-04-05 20:41:53 +00:00
if has("win32") && executable("cygpath")
" assuming cygwin
2008-06-24 22:58:06 +00:00
let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile)),'\n$','','e')
2006-04-05 20:41:53 +00:00
endif
" call Decho("tarfile<".tarfile.">")
" call Decho("fname<".fname.">")
2005-11-23 21:25:05 +00:00
2008-06-24 22:58:06 +00:00
if fname =~ '\.gz$' && executable("zcat")
let decmp= "|zcat"
let doro = 1
elseif fname =~ '\.bz2$' && executable("bzcat")
let decmp= "|bzcat"
let doro = 1
else
let decmp=""
let doro = 0
if fname =~ '\.gz$\|\.bz2$\|\.Z$\|\.zip$'
setlocal bin
endif
endif
2005-11-23 21:25:05 +00:00
if tarfile =~# '\.\(gz\|tgz\)$'
2008-06-24 22:58:06 +00:00
" call Decho("5: exe silent r! gzip -d -c -- ".s:Escape(tarfile)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.s:Escape(fname))
exe "silent r! gzip -d -c -- ".s:Escape(tarfile)."| ".g:tar_cmd." -".g:tar_readoptions." - ".s:Escape(fname).decmp
elseif tarfile =~# '\.lrp$'
" call Decho("6: exe silent r! cat ".s:Escape(tarfile)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".s:Escape(fname).decmp)
exe "silent r! cat -- ".s:Escape(tarfile)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".s:Escape(fname).decmp
2005-12-29 22:51:09 +00:00
elseif tarfile =~# '\.bz2$'
2008-06-24 22:58:06 +00:00
" call Decho("7: exe silent r! bzip2 -d -c ".s:Escape(tarfile)."| ".g:tar_cmd." -".g:tar_readoptions." - ".s:Escape(fname).decmp)
exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile)."| ".g:tar_cmd." -".g:tar_readoptions." - ".s:Escape(fname).decmp
2005-11-23 21:25:05 +00:00
else
2008-06-24 22:58:06 +00:00
" call Decho("8: exe silent r! ".g:tar_cmd." -".g:tar_readoptions." -- ".s:Escape(tarfile)." ".s:Escape(fname))
exe "silent r! ".g:tar_cmd." -".g:tar_readoptions." ".s:Escape(tarfile)." -- ".s:Escape(fname).decmp
2005-11-23 21:25:05 +00:00
endif
2008-06-24 22:58:06 +00:00
if doro
" because the reverse process of compressing changed files back into the tarball is not currently supported
setlocal ro
endif
2005-11-23 21:25:05 +00:00
let w:tarfile= a:fname
2008-06-24 22:58:06 +00:00
exe "file tarfile::".fname
2005-11-23 21:25:05 +00:00
" cleanup
0d
set nomod
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-11-23 21:25:05 +00:00
" call Dret("tar#Read : w:tarfile<".w:tarfile.">")
endfun
" ---------------------------------------------------------------------
" tar#Write: {{{2
fun! tar#Write(fname)
" call Dfunc("tar#Write(fname<".a:fname.">) w:tarfile<".w:tarfile."> tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
2005-11-28 23:05:55 +00:00
let repkeep= &report
set report=10
2005-11-23 21:25:05 +00:00
2005-09-14 21:40:12 +00:00
" sanity checks
2006-04-05 20:41:53 +00:00
if !executable(g:tar_cmd)
2007-05-05 18:24:42 +00:00
redraw!
2006-04-05 20:41:53 +00:00
echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-09-14 21:40:12 +00:00
" call Dret("tar#Write")
return
endif
if !exists("*mkdir")
2007-05-05 18:24:42 +00:00
redraw!
2005-11-23 21:25:05 +00:00
echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-09-14 21:40:12 +00:00
" call Dret("tar#Write")
return
endif
let curdir= getcwd()
let tmpdir= tempname()
" call Decho("orig tempname<".tmpdir.">")
if tmpdir =~ '\.'
let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
endif
" call Decho("tmpdir<".tmpdir.">")
call mkdir(tmpdir,"p")
" attempt to change to the indicated directory
try
2008-06-24 22:58:06 +00:00
exe "cd ".fnameescape(tmpdir)
2005-09-14 21:40:12 +00:00
catch /^Vim\%((\a\+)\)\=:E344/
2007-05-05 18:24:42 +00:00
redraw!
2005-11-23 21:25:05 +00:00
echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-09-14 21:40:12 +00:00
" call Dret("tar#Write")
return
endtry
" call Decho("current directory now: ".getcwd())
2005-11-23 21:25:05 +00:00
" place temporary files under .../_ZIPVIM_/
if isdirectory("_ZIPVIM_")
call s:Rmdir("_ZIPVIM_")
2005-09-14 21:40:12 +00:00
endif
2005-11-23 21:25:05 +00:00
call mkdir("_ZIPVIM_")
cd _ZIPVIM_
2005-09-14 21:40:12 +00:00
" call Decho("current directory now: ".getcwd())
2008-06-24 22:58:06 +00:00
let tarfile = substitute(w:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
let fname = substitute(w:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
2005-11-23 21:25:05 +00:00
" handle compressed archives
if tarfile =~# '\.gz'
2008-06-24 22:58:06 +00:00
call system("gzip -d -- ".tarfile)
2005-11-23 21:25:05 +00:00
let tarfile = substitute(tarfile,'\.gz','','e')
2008-06-24 22:58:06 +00:00
let compress= "gzip ".s:Escape(tarfile)
2005-11-23 21:25:05 +00:00
elseif tarfile =~# '\.tgz'
2008-06-24 22:58:06 +00:00
call system("gzip -d -- ".s:Escape(tarfile))
2005-11-23 21:25:05 +00:00
let tarfile = substitute(tarfile,'\.tgz','.tar','e')
2008-06-24 22:58:06 +00:00
let compress= "gzip -- ".s:Escape(tarfile)
2005-11-23 21:25:05 +00:00
let tgz = 1
elseif tarfile =~# '\.bz2'
2008-06-24 22:58:06 +00:00
call system("bzip2 -d -- ".s:Escape(tarfile))
2005-11-23 21:25:05 +00:00
let tarfile = substitute(tarfile,'\.bz2','','e')
2008-06-24 22:58:06 +00:00
let compress= "bzip2 -- ".s:Escape(tarfile)
2005-09-14 21:40:12 +00:00
endif
2008-06-24 22:58:06 +00:00
" call Decho("tarfile<".tarfile.">")
" call Decho("compress<".compress.">")
2005-09-14 21:40:12 +00:00
if v:shell_error != 0
2007-05-05 18:24:42 +00:00
redraw!
2005-11-23 21:25:05 +00:00
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-09-14 21:40:12 +00:00
else
2005-11-23 21:25:05 +00:00
" call Decho("tarfile<".tarfile."> fname<".fname.">")
2005-12-29 22:51:09 +00:00
if fname =~ '/'
let dirpath = substitute(fname,'/[^/]\+$','','e')
if executable("cygpath")
let dirpath = substitute(system("cygpath ".dirpath),'\n','','e')
endif
call mkdir(dirpath,"p")
endif
2005-11-23 21:25:05 +00:00
if tarfile !~ '/'
let tarfile= curdir.'/'.tarfile
endif
" call Decho("tarfile<".tarfile."> fname<".fname.">")
2008-06-24 22:58:06 +00:00
exe "w! ".fnameescape(fname)
2005-11-23 21:25:05 +00:00
if executable("cygpath")
2008-06-24 22:58:06 +00:00
let tarfile = substitute(system("cygpath ".s:Escape(tarfile)),'\n','','e')
2005-11-23 21:25:05 +00:00
endif
" delete old file from tarfile
2008-06-24 22:58:06 +00:00
" call Decho("system(tar --delete -f ".s:Escape(tarfile)." -- ".s:Escape(fname).")")
call system("tar --delete -f ".s:Escape(tarfile)." -- ".s:Escape(fname))
2005-11-23 21:25:05 +00:00
if v:shell_error != 0
2007-05-05 18:24:42 +00:00
redraw!
2008-06-24 22:58:06 +00:00
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-11-23 21:25:05 +00:00
else
" update tarfile with new file
2008-06-24 22:58:06 +00:00
" call Decho("tar -".g:tar_writeoptions." ".s:Escape(tarfile)." -- ".s:Escape(fname))
call system("tar -".g:tar_writeoptions." ".s:Escape(tarfile)." -- ".s:Escape(fname))
2005-11-23 21:25:05 +00:00
if v:shell_error != 0
2007-05-05 18:24:42 +00:00
redraw!
2008-06-24 22:58:06 +00:00
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
2007-05-05 18:24:42 +00:00
" call inputsave()|call input("Press <cr> to continue")|call inputrestore()
2005-11-23 21:25:05 +00:00
elseif exists("compress")
" call Decho("call system(".compress.")")
call system(compress)
if exists("tgz")
" call Decho("rename(".tarfile.".gz,".substitute(tarfile,'\.tar$','.tgz','e').")")
call rename(tarfile.".gz",substitute(tarfile,'\.tar$','.tgz','e'))
endif
endif
endif
" support writing tarfiles across a network
if s:tblfile_{winnr()} =~ '^\a\+://'
" call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
let tblfile= s:tblfile_{winnr()}
1split|enew
let binkeep= &binary
let eikeep = &ei
set binary ei=all
exe "e! ".tarfile
call netrw#NetWrite(tblfile)
let &ei = eikeep
let &binary = binkeep
q!
unlet s:tblfile_{winnr()}
endif
2005-09-14 21:40:12 +00:00
endif
" cleanup and restore current directory
cd ..
2005-11-23 21:25:05 +00:00
call s:Rmdir("_ZIPVIM_")
2005-09-14 21:40:12 +00:00
exe "cd ".escape(curdir,' \')
setlocal nomod
2005-11-28 23:05:55 +00:00
let &report= repkeep
2005-09-14 21:40:12 +00:00
" call Dret("tar#Write")
endfun
" ---------------------------------------------------------------------
2005-11-23 21:25:05 +00:00
" Rmdir: {{{2
2005-09-14 21:40:12 +00:00
fun! s:Rmdir(fname)
" call Dfunc("Rmdir(fname<".a:fname.">)")
if has("unix")
2008-06-24 22:58:06 +00:00
call system("/bin/rm -rf -- ".s:Escape(a:fname))
2005-09-14 21:40:12 +00:00
elseif has("win32") || has("win95") || has("win64") || has("win16")
if &shell =~? "sh$"
2008-06-24 22:58:06 +00:00
call system("/bin/rm -rf -- ".s:Escape(a:fname))
2005-09-14 21:40:12 +00:00
else
2008-06-24 22:58:06 +00:00
call system("del /S ".s:Escape(a:fname))
2005-09-14 21:40:12 +00:00
endif
endif
" call Dret("Rmdir")
endfun
2008-06-24 22:58:06 +00:00
" ---------------------------------------------------------------------
" s:Escape: {{{2
fun s:Escape(name)
" shellescape() was added by patch 7.0.111
if exists("*shellescape")
let qnameq= shellescape(a:name)
else
let qnameq= g:tar_shq . a:name . g:tar_shq
endif
return qnameq
endfun
" ---------------------------------------------------------------------
2005-11-23 21:25:05 +00:00
" Modelines And Restoration: {{{1
let &cpo= s:keepcpo
unlet s:keepcpo
2008-06-24 22:58:06 +00:00
" vim:ts=8 fdm=marker