Karsten Hopp cf9f5a
" zip.vim: Handles browsing zipfiles
Karsten Hopp cf9f5a
"            AUTOLOAD PORTION
Karsten Hopp cf9f5a
" Date:		Jul 30, 2008
Karsten Hopp cf9f5a
" Version:	22
Karsten Hopp cf9f5a
" Maintainer:	Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
Karsten Hopp cf9f5a
" License:	Vim License  (see vim's :help license)
Karsten Hopp cf9f5a
" Copyright:    Copyright (C) 2005-2008 Charles E. Campbell, Jr. {{{1
Karsten Hopp cf9f5a
"               Permission is hereby granted to use and distribute this code,
Karsten Hopp cf9f5a
"               with or without modifications, provided that this copyright
Karsten Hopp cf9f5a
"               notice is copied with it. Like anything else that's free,
Karsten Hopp cf9f5a
"               zip.vim and zipPlugin.vim are provided *as is* and comes with
Karsten Hopp cf9f5a
"               no warranty of any kind, either expressed or implied. By using
Karsten Hopp cf9f5a
"               this plugin, you agree that in no event will the copyright
Karsten Hopp cf9f5a
"               holder be liable for any damages resulting from the use
Karsten Hopp cf9f5a
"               of this software.
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" Load Once: {{{1
Karsten Hopp cf9f5a
let s:keepcpo= &cpo
Karsten Hopp cf9f5a
set cpo&vim
Karsten Hopp cf9f5a
if &cp || exists("g:loaded_zip") || v:version < 700
Karsten Hopp cf9f5a
 finish
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
let g:loaded_zip     = "v22"
Karsten Hopp cf9f5a
let s:zipfile_escape = ' ?&;\'
Karsten Hopp cf9f5a
let s:ERROR          = 2
Karsten Hopp cf9f5a
let s:WARNING        = 1
Karsten Hopp cf9f5a
let s:NOTE           = 0
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
"  Global Values: {{{1
Karsten Hopp cf9f5a
if !exists("g:zip_shq")
Karsten Hopp cf9f5a
 if &shq != ""
Karsten Hopp cf9f5a
  let g:zip_shq= &shq
Karsten Hopp cf9f5a
 elseif has("unix")
Karsten Hopp cf9f5a
  let g:zip_shq= "'"
Karsten Hopp cf9f5a
 else
Karsten Hopp cf9f5a
  let g:zip_shq= '"'
Karsten Hopp cf9f5a
 endif
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
if !exists("g:zip_zipcmd")
Karsten Hopp cf9f5a
 let g:zip_zipcmd= "zip"
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
if !exists("g:zip_unzipcmd")
Karsten Hopp cf9f5a
 let g:zip_unzipcmd= "unzip"
Karsten Hopp cf9f5a
endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ----------------
Karsten Hopp cf9f5a
"  Functions: {{{1
Karsten Hopp cf9f5a
" ----------------
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" zip#Browse: {{{2
Karsten Hopp cf9f5a
fun! zip#Browse(zipfile)
Karsten Hopp cf9f5a
"  call Dfunc("zip#Browse(zipfile<".a:zipfile.">)")
Karsten Hopp cf9f5a
  let repkeep= &report
Karsten Hopp cf9f5a
  set report=10
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " sanity checks
Karsten Hopp cf9f5a
  if !exists("*fnameescape")
Karsten Hopp cf9f5a
   if &verbose > 1
Karsten Hopp cf9f5a
    echoerr "the zip plugin is not available (your vim doens't support fnameescape())"
Karsten Hopp cf9f5a
   endif
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if !executable(g:zip_unzipcmd)
Karsten Hopp cf9f5a
   redraw!
Karsten Hopp cf9f5a
   echohl Error | echo "***error*** (zip#Browse) unzip not available on your system"
Karsten Hopp cf9f5a
"   call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
   let &report= repkeep
Karsten Hopp cf9f5a
"   call Dret("zip#Browse")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if !filereadable(a:zipfile)
Karsten Hopp cf9f5a
   if a:zipfile !~# '^\a\+://'
Karsten Hopp cf9f5a
    " if its an url, don't complain, let url-handlers such as vim do its thing
Karsten Hopp cf9f5a
    redraw!
Karsten Hopp cf9f5a
    echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
Karsten Hopp cf9f5a
"    call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
   endif
Karsten Hopp cf9f5a
   let &report= repkeep
Karsten Hopp cf9f5a
"   call Dret("zip#Browse : file<".a:zipfile."> not readable")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Decho("passed sanity checks")
Karsten Hopp cf9f5a
  if &ma != 1
Karsten Hopp cf9f5a
   set ma
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  let b:zipfile= a:zipfile
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  setlocal noswapfile
Karsten Hopp cf9f5a
  setlocal buftype=nofile
Karsten Hopp cf9f5a
  setlocal bufhidden=hide
Karsten Hopp cf9f5a
  setlocal nobuflisted
Karsten Hopp cf9f5a
  setlocal nowrap
Karsten Hopp cf9f5a
  set ft=tar
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " give header
Karsten Hopp cf9f5a
  let lastline= line("$")
Karsten Hopp cf9f5a
  call setline(lastline+1,'" zip.vim version '.g:loaded_zip)
Karsten Hopp cf9f5a
  call setline(lastline+2,'" Browsing zipfile '.a:zipfile)
Karsten Hopp cf9f5a
  call setline(lastline+3,'" Select a file with cursor and press ENTER')
Karsten Hopp cf9f5a
  $put =''
Karsten Hopp cf9f5a
  0d
Karsten Hopp cf9f5a
  $
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
"  call Decho("exe silent r! ".g:zip_unzipcmd." -l -- ".s:Escape(a:zipfile,1))
Karsten Hopp cf9f5a
  exe "silent r! ".g:zip_unzipcmd." -l -- ".s:Escape(a:zipfile,1)
Karsten Hopp cf9f5a
  if v:shell_error != 0
Karsten Hopp cf9f5a
   redraw!
Karsten Hopp cf9f5a
   echohl WarningMsg | echo "***warning*** (zip#Browse) ".fnameescape(a:zipfile)." is not a zip file" | echohl None
Karsten Hopp cf9f5a
"   call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
   silent %d
Karsten Hopp cf9f5a
   let eikeep= &ei
Karsten Hopp cf9f5a
   set ei=BufReadCmd,FileReadCmd
Karsten Hopp cf9f5a
   exe "r ".fnameescape(a:zipfile)
Karsten Hopp cf9f5a
   let &ei= eikeep
Karsten Hopp cf9f5a
   1d
Karsten Hopp cf9f5a
"   call Dret("zip#Browse")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Decho("line 6: ".getline(6))
Karsten Hopp cf9f5a
  let namecol= stridx(getline(6),'Name') + 1
Karsten Hopp cf9f5a
"  call Decho("namecol=".namecol)
Karsten Hopp cf9f5a
  4,$g/^\s*----/d
Karsten Hopp cf9f5a
  4,$g/^\s*\a/d
Karsten Hopp cf9f5a
  $d
Karsten Hopp cf9f5a
  if namecol > 0
Karsten Hopp cf9f5a
   exe 'silent 4,$s/^.*\%'.namecol.'c//'
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  setlocal noma nomod ro
Karsten Hopp cf9f5a
  noremap <silent> <buffer> <cr> :call <SID>ZipBrowseSelect()<cr>
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  let &report= repkeep
Karsten Hopp cf9f5a
"  call Dret("zip#Browse")
Karsten Hopp cf9f5a
endfun
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" ZipBrowseSelect: {{{2
Karsten Hopp cf9f5a
fun! s:ZipBrowseSelect()
Karsten Hopp cf9f5a
"  call Dfunc("ZipBrowseSelect() zipfile<".b:zipfile."> curfile<".expand("%").">")
Karsten Hopp cf9f5a
  let repkeep= &report
Karsten Hopp cf9f5a
  set report=10
Karsten Hopp cf9f5a
  let fname= getline(".")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " sanity check
Karsten Hopp cf9f5a
  if fname =~ '^"'
Karsten Hopp cf9f5a
   let &report= repkeep
Karsten Hopp cf9f5a
"   call Dret("ZipBrowseSelect")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if fname =~ '/$'
Karsten Hopp cf9f5a
   redraw!
Karsten Hopp cf9f5a
   echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None
Karsten Hopp cf9f5a
"   call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
   let &report= repkeep
Karsten Hopp cf9f5a
"   call Dret("ZipBrowseSelect")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
"  call Decho("fname<".fname.">")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " get zipfile to the new-window
Karsten Hopp cf9f5a
  let zipfile = b:zipfile
Karsten Hopp cf9f5a
  let curfile= expand("%")
Karsten Hopp cf9f5a
"  call Decho("zipfile<".zipfile.">")
Karsten Hopp cf9f5a
"  call Decho("curfile<".curfile.">")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  new
Karsten Hopp cf9f5a
  if !exists("g:zip_nomax") || g:zip_nomax == 0
Karsten Hopp cf9f5a
   wincmd _
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  let s:zipfile_{winnr()}= curfile
Karsten Hopp cf9f5a
"  call Decho("exe e ".fnameescape("zipfile:".zipfile.'::'.fname))
Karsten Hopp cf9f5a
  exe "e ".fnameescape("zipfile:".zipfile.'::'.fname)
Karsten Hopp cf9f5a
  filetype detect
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  let &report= repkeep
Karsten Hopp cf9f5a
"  call Dret("ZipBrowseSelect : s:zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
Karsten Hopp cf9f5a
endfun
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" zip#Read: {{{2
Karsten Hopp cf9f5a
fun! zip#Read(fname,mode)
Karsten Hopp cf9f5a
"  call Dfunc("zip#Read(fname<".a:fname.">,mode=".a:mode.")")
Karsten Hopp cf9f5a
  let repkeep= &report
Karsten Hopp cf9f5a
  set report=10
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  if has("unix")
Karsten Hopp cf9f5a
   let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
Karsten Hopp cf9f5a
   let fname   = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
   let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
Karsten Hopp cf9f5a
   let fname   = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
Karsten Hopp cf9f5a
   let fname = substitute(fname, '[', '[[]', 'g')
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Decho("zipfile<".zipfile.">")
Karsten Hopp cf9f5a
"  call Decho("fname  <".fname.">")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
"  call Decho("exe r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1))
Karsten Hopp cf9f5a
  exe "silent r! ".g:zip_unzipcmd." -p -- ".s:Escape(zipfile,1)." ".s:Escape(fname,1)
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " cleanup
Karsten Hopp cf9f5a
  0d
Karsten Hopp cf9f5a
  set nomod
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  let &report= repkeep
Karsten Hopp cf9f5a
"  call Dret("zip#Read")
Karsten Hopp cf9f5a
endfun
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" zip#Write: {{{2
Karsten Hopp cf9f5a
fun! zip#Write(fname)
Karsten Hopp cf9f5a
"  call Dfunc("zip#Write(fname<".a:fname.">) zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
Karsten Hopp cf9f5a
  let repkeep= &report
Karsten Hopp cf9f5a
  set report=10
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " sanity checks
Karsten Hopp cf9f5a
  if !executable(g:zip_zipcmd)
Karsten Hopp cf9f5a
   redraw!
Karsten Hopp cf9f5a
   echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the zip pgm" | echohl None
Karsten Hopp cf9f5a
"   call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
   let &report= repkeep
Karsten Hopp cf9f5a
"   call Dret("zip#Write")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if !exists("*mkdir")
Karsten Hopp cf9f5a
   redraw!
Karsten Hopp cf9f5a
   echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None
Karsten Hopp cf9f5a
"   call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
   let &report= repkeep
Karsten Hopp cf9f5a
"   call Dret("zip#Write")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  let curdir= getcwd()
Karsten Hopp cf9f5a
  let tmpdir= tempname()
Karsten Hopp cf9f5a
"  call Decho("orig tempname<".tmpdir.">")
Karsten Hopp cf9f5a
  if tmpdir =~ '\.'
Karsten Hopp cf9f5a
   let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Decho("tmpdir<".tmpdir.">")
Karsten Hopp cf9f5a
  call mkdir(tmpdir,"p")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " attempt to change to the indicated directory
Karsten Hopp cf9f5a
  if s:ChgDir(tmpdir,s:ERROR,"(zip#Write) cannot cd to temporary directory")
Karsten Hopp cf9f5a
   let &report= repkeep
Karsten Hopp cf9f5a
"   call Dret("zip#Write")
Karsten Hopp cf9f5a
   return
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Decho("current directory now: ".getcwd())
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  " place temporary files under .../_ZIPVIM_/
Karsten Hopp cf9f5a
  if isdirectory("_ZIPVIM_")
Karsten Hopp cf9f5a
   call s:Rmdir("_ZIPVIM_")
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  call mkdir("_ZIPVIM_")
Karsten Hopp cf9f5a
  cd _ZIPVIM_
Karsten Hopp cf9f5a
"  call Decho("current directory now: ".getcwd())
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  if has("unix")
Karsten Hopp cf9f5a
   let zipfile = substitute(a:fname,'zipfile:\(.\{-}\)::[^\\].*$','\1','')
Karsten Hopp cf9f5a
   let fname   = substitute(a:fname,'zipfile:.\{-}::\([^\\].*\)$','\1','')
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
   let zipfile = substitute(a:fname,'^.\{-}zipfile:\(.\{-}\)::[^\\].*$','\1','')
Karsten Hopp cf9f5a
   let fname   = substitute(a:fname,'^.\{-}zipfile:.\{-}::\([^\\].*\)$','\1','')
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Decho("zipfile<".zipfile.">")
Karsten Hopp cf9f5a
"  call Decho("fname  <".fname.">")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  if fname =~ '/'
Karsten Hopp cf9f5a
   let dirpath = substitute(fname,'/[^/]\+$','','e')
Karsten Hopp cf9f5a
   if executable("cygpath")
Karsten Hopp cf9f5a
    let dirpath = substitute(system("cygpath ".s:Escape(dirpath,0)),'\n','','e')
Karsten Hopp cf9f5a
   endif
Karsten Hopp cf9f5a
"   call Decho("mkdir(dirpath<".dirpath.">,p)")
Karsten Hopp cf9f5a
   call mkdir(dirpath,"p")
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  if zipfile !~ '/'
Karsten Hopp cf9f5a
   let zipfile= curdir.'/'.zipfile
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Decho("zipfile<".zipfile."> fname<".fname.">")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  exe "w! ".fnameescape(fname)
Karsten Hopp cf9f5a
  if executable("cygpath")
Karsten Hopp cf9f5a
   let zipfile = substitute(system("cygpath ".s:Escape(zipfile,0)),'\n','','e')
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
Karsten Hopp cf9f5a
    let fname = substitute(fname, '[', '[[]', 'g')
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
"  call Decho(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
Karsten Hopp cf9f5a
  call system(g:zip_zipcmd." -u ".s:Escape(fnamemodify(zipfile,":p"),0)." ".s:Escape(fname,0))
Karsten Hopp cf9f5a
  if v:shell_error != 0
Karsten Hopp cf9f5a
   redraw!
Karsten Hopp cf9f5a
   echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None
Karsten Hopp cf9f5a
"   call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  elseif s:zipfile_{winnr()} =~ '^\a\+://'
Karsten Hopp cf9f5a
   " support writing zipfiles across a network
Karsten Hopp cf9f5a
   let netzipfile= s:zipfile_{winnr()}
Karsten Hopp cf9f5a
"   call Decho("handle writing <".zipfile."> across network as <".netzipfile.">")
Karsten Hopp cf9f5a
   1split|enew
Karsten Hopp cf9f5a
   let binkeep= &binary
Karsten Hopp cf9f5a
   let eikeep = &ei
Karsten Hopp cf9f5a
   set binary ei=all
Karsten Hopp cf9f5a
   exe "e! ".fnameescape(zipfile)
Karsten Hopp cf9f5a
   call netrw#NetWrite(netzipfile)
Karsten Hopp cf9f5a
   let &ei     = eikeep
Karsten Hopp cf9f5a
   let &binary = binkeep
Karsten Hopp cf9f5a
   q!
Karsten Hopp cf9f5a
   unlet s:zipfile_{winnr()}
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
  
Karsten Hopp cf9f5a
  " cleanup and restore current directory
Karsten Hopp cf9f5a
  cd ..
Karsten Hopp cf9f5a
  call s:Rmdir("_ZIPVIM_")
Karsten Hopp cf9f5a
  call s:ChgDir(curdir,s:WARNING,"(zip#Write) unable to return to ".curdir."!")
Karsten Hopp cf9f5a
  call s:Rmdir(tmpdir)
Karsten Hopp cf9f5a
  setlocal nomod
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  let &report= repkeep
Karsten Hopp cf9f5a
"  call Dret("zip#Write")
Karsten Hopp cf9f5a
endfun
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" s:Escape: {{{2
Karsten Hopp cf9f5a
fun! s:Escape(fname,isfilt)
Karsten Hopp cf9f5a
"  call Dfunc("QuoteFileDir(fname<".a:fname."> isfilt=".a:isfilt.")")
Karsten Hopp cf9f5a
  if exists("*shellescape")
Karsten Hopp cf9f5a
   if a:isfilt
Karsten Hopp cf9f5a
    let qnameq= shellescape(a:fname,1)
Karsten Hopp cf9f5a
   else
Karsten Hopp cf9f5a
    let qnameq= shellescape(a:fname)
Karsten Hopp cf9f5a
   endif
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
   let qnameq= g:zip_shq.escape(a:fname,g:zip_shq).g:zip_shq
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Dret("QuoteFileDir <".qnameq.">")
Karsten Hopp cf9f5a
  return qnameq
Karsten Hopp cf9f5a
endfun
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" ChgDir: {{{2
Karsten Hopp cf9f5a
fun! s:ChgDir(newdir,errlvl,errmsg)
Karsten Hopp cf9f5a
"  call Dfunc("ChgDir(newdir<".a:newdir."> errlvl=".a:errlvl."  errmsg<".a:errmsg.">)")
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
  try
Karsten Hopp cf9f5a
   exe "cd ".fnameescape(a:newdir)
Karsten Hopp cf9f5a
  catch /^Vim\%((\a\+)\)\=:E344/
Karsten Hopp cf9f5a
   redraw!
Karsten Hopp cf9f5a
   if a:errlvl == s:NOTE
Karsten Hopp cf9f5a
    echo "***note*** ".a:errmsg
Karsten Hopp cf9f5a
   elseif a:errlvl == s:WARNING
Karsten Hopp cf9f5a
    echohl WarningMsg | echo "***warning*** ".a:errmsg | echohl NONE
Karsten Hopp cf9f5a
   elseif a:errlvl == s:ERROR
Karsten Hopp cf9f5a
    echohl Error | echo "***error*** ".a:errmsg | echohl NONE
Karsten Hopp cf9f5a
   endif
Karsten Hopp cf9f5a
"   call inputsave()|call input("Press <cr> to continue")|call inputrestore()
Karsten Hopp cf9f5a
"   call Dret("ChgDir 1")
Karsten Hopp cf9f5a
   return 1
Karsten Hopp cf9f5a
  endtry
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
"  call Dret("ChgDir 0")
Karsten Hopp cf9f5a
  return 0
Karsten Hopp cf9f5a
endfun
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ---------------------------------------------------------------------
Karsten Hopp cf9f5a
" s:Rmdir: {{{2
Karsten Hopp cf9f5a
fun! s:Rmdir(fname)
Karsten Hopp cf9f5a
"  call Dfunc("Rmdir(fname<".a:fname.">)")
Karsten Hopp cf9f5a
  if (has("win32") || has("win95") || has("win64") || has("win16")) && &shell !~? 'sh$'
Karsten Hopp cf9f5a
   call system("rmdir /S/Q ".s:Escape(a:fname,0))
Karsten Hopp cf9f5a
  else
Karsten Hopp cf9f5a
   call system("/bin/rm -rf ".s:Escape(a:fname,0))
Karsten Hopp cf9f5a
  endif
Karsten Hopp cf9f5a
"  call Dret("Rmdir")
Karsten Hopp cf9f5a
endfun
Karsten Hopp cf9f5a
Karsten Hopp cf9f5a
" ------------------------------------------------------------------------
Karsten Hopp cf9f5a
" Modelines And Restoration: {{{1
Karsten Hopp cf9f5a
let &cpo= s:keepcpo
Karsten Hopp cf9f5a
unlet s:keepcpo
Karsten Hopp cf9f5a
" vim:ts=8 fdm=marker