mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
runtime/tar: 2963456ff2b740244b3a064785fe681b1998d75e
Port tar files for release v31 only.
This commit is contained in:
parent
18f90336cb
commit
1d84277738
@ -1,13 +1,13 @@
|
|||||||
" tar.vim: Handles browsing tarfiles
|
" tar.vim: Handles browsing tarfiles
|
||||||
" AUTOLOAD PORTION
|
" AUTOLOAD PORTION
|
||||||
" Date: Apr 17, 2013
|
" Date: Jan 07, 2020
|
||||||
" Version: 29
|
" Version: 32
|
||||||
" Maintainer: Charles E Campbell <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
|
" Maintainer: Charles E Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
|
||||||
" License: Vim License (see vim's :help license)
|
" License: Vim License (see vim's :help license)
|
||||||
"
|
"
|
||||||
" Contains many ideas from Michael Toren's <tar.vim>
|
" Contains many ideas from Michael Toren's <tar.vim>
|
||||||
"
|
"
|
||||||
" Copyright: Copyright (C) 2005-2011 Charles E. Campbell {{{1
|
" Copyright: Copyright (C) 2005-2017 Charles E. Campbell {{{1
|
||||||
" Permission is hereby granted to use and distribute this code,
|
" Permission is hereby granted to use and distribute this code,
|
||||||
" with or without modifications, provided that this copyright
|
" with or without modifications, provided that this copyright
|
||||||
" notice is copied with it. Like anything else that's free,
|
" notice is copied with it. Like anything else that's free,
|
||||||
@ -22,7 +22,7 @@
|
|||||||
if &cp || exists("g:loaded_tar")
|
if &cp || exists("g:loaded_tar")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_tar= "v29"
|
let g:loaded_tar= "v32"
|
||||||
if v:version < 702
|
if v:version < 702
|
||||||
echohl WarningMsg
|
echohl WarningMsg
|
||||||
echo "***warning*** this version of tar needs vim 7.2"
|
echo "***warning*** this version of tar needs vim 7.2"
|
||||||
@ -48,6 +48,9 @@ endif
|
|||||||
if !exists("g:tar_writeoptions")
|
if !exists("g:tar_writeoptions")
|
||||||
let g:tar_writeoptions= "uf"
|
let g:tar_writeoptions= "uf"
|
||||||
endif
|
endif
|
||||||
|
if !exists("g:tar_delfile")
|
||||||
|
let g:tar_delfile="--delete -f"
|
||||||
|
endif
|
||||||
if !exists("g:netrw_cygwin")
|
if !exists("g:netrw_cygwin")
|
||||||
if has("win32") || has("win95") || has("win64") || has("win16")
|
if has("win32") || has("win95") || has("win64") || has("win16")
|
||||||
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
|
if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
|
||||||
@ -109,6 +112,7 @@ fun! tar#Browse(tarfile)
|
|||||||
" sanity checks
|
" sanity checks
|
||||||
if !executable(g:tar_cmd)
|
if !executable(g:tar_cmd)
|
||||||
redraw!
|
redraw!
|
||||||
|
" call Decho('***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system')
|
||||||
echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
|
echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
|
||||||
let &report= repkeep
|
let &report= repkeep
|
||||||
" call Dret("tar#Browse")
|
" call Dret("tar#Browse")
|
||||||
@ -117,8 +121,9 @@ fun! tar#Browse(tarfile)
|
|||||||
if !filereadable(a:tarfile)
|
if !filereadable(a:tarfile)
|
||||||
" call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
|
" call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
|
||||||
if a:tarfile !~# '^\a\+://'
|
if a:tarfile !~# '^\a\+://'
|
||||||
" if it's an url, don't complain, let url-handlers such as vim do its thing
|
" if its an url, don't complain, let url-handlers such as vim do its thing
|
||||||
redraw!
|
redraw!
|
||||||
|
" call Decho("***error*** (tar#Browse) File not readable<".a:tarfile.">")
|
||||||
echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
|
echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
|
||||||
endif
|
endif
|
||||||
let &report= repkeep
|
let &report= repkeep
|
||||||
@ -152,12 +157,27 @@ fun! tar#Browse(tarfile)
|
|||||||
" assuming cygwin
|
" assuming cygwin
|
||||||
let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
|
let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let curlast= line("$")
|
let curlast= line("$")
|
||||||
if tarfile =~# '\.\(gz\|tgz\)$'
|
|
||||||
let gzip_command = s:get_gzip_command(tarfile)
|
if tarfile =~# '\.\(gz\)$'
|
||||||
" call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
|
" call Decho("1: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
|
||||||
exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
|
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
|
||||||
|
|
||||||
|
elseif tarfile =~# '\.\(tgz\)$' || tarfile =~# '\.\(tbz\)$' || tarfile =~# '\.\(txz\)$'
|
||||||
|
if has("unix") && executable("file")
|
||||||
|
let filekind= system("file ".shellescape(tarfile,1)) =~ "bzip2"
|
||||||
|
else
|
||||||
|
let filekind= ""
|
||||||
|
endif
|
||||||
|
|
||||||
|
if filekind =~ "bzip2"
|
||||||
|
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
|
||||||
|
elseif filekind =~ "XZ"
|
||||||
|
exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
|
||||||
|
else
|
||||||
|
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
|
||||||
|
endif
|
||||||
|
|
||||||
elseif tarfile =~# '\.lrp'
|
elseif tarfile =~# '\.lrp'
|
||||||
" call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
|
" call Decho("2: exe silent r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
|
||||||
exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
|
exe "sil! r! cat -- ".shellescape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
|
||||||
@ -184,7 +204,7 @@ fun! tar#Browse(tarfile)
|
|||||||
" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
|
" call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)')
|
if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~# '\c\%(warning\|error\|inappropriate\|unrecognized\)')
|
||||||
redraw!
|
redraw!
|
||||||
echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
|
echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
|
||||||
keepj sil! %d
|
keepj sil! %d
|
||||||
@ -197,8 +217,13 @@ fun! tar#Browse(tarfile)
|
|||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" set up maps supported for tar
|
||||||
setlocal noma nomod ro
|
setlocal noma nomod ro
|
||||||
noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
|
noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
|
||||||
|
noremap <silent> <buffer> x :call tar#Extract()<cr>
|
||||||
|
if &mouse != ""
|
||||||
|
noremap <silent> <buffer> <leftmouse> <leftmouse>:call <SID>TarBrowseSelect()<cr>
|
||||||
|
endif
|
||||||
|
|
||||||
let &report= repkeep
|
let &report= repkeep
|
||||||
" call Dret("tar#Browse : b:tarfile<".b:tarfile.">")
|
" call Dret("tar#Browse : b:tarfile<".b:tarfile.">")
|
||||||
@ -235,7 +260,8 @@ fun! s:TarBrowseSelect()
|
|||||||
let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
|
let tarfile=substitute(system("cygpath -u ".shellescape(tarfile,0)),'\n$','','e')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
new
|
" open a new window (tar#Read will read a file into it)
|
||||||
|
noswapfile new
|
||||||
if !exists("g:tar_nomax") || g:tar_nomax == 0
|
if !exists("g:tar_nomax") || g:tar_nomax == 0
|
||||||
wincmd _
|
wincmd _
|
||||||
endif
|
endif
|
||||||
@ -267,7 +293,7 @@ fun! tar#Read(fname,mode)
|
|||||||
if fname =~ '\.bz2$' && executable("bzcat")
|
if fname =~ '\.bz2$' && executable("bzcat")
|
||||||
let decmp= "|bzcat"
|
let decmp= "|bzcat"
|
||||||
let doro = 1
|
let doro = 1
|
||||||
elseif fname =~ '\.gz$' && executable("zcat")
|
elseif fname =~ '\.t\=gz$' && executable("zcat")
|
||||||
let decmp= "|zcat"
|
let decmp= "|zcat"
|
||||||
let doro = 1
|
let doro = 1
|
||||||
elseif fname =~ '\.lzma$' && executable("lzcat")
|
elseif fname =~ '\.lzma$' && executable("lzcat")
|
||||||
@ -291,20 +317,29 @@ fun! tar#Read(fname,mode)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if tarfile =~# '\.bz2$'
|
if tarfile =~# '\.bz2$'
|
||||||
" call Decho("7: exe silent r! bzip2 -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
|
|
||||||
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
elseif tarfile =~# '\.\(gz\|tgz\)$'
|
elseif tarfile =~# '\.\(gz\)$'
|
||||||
let gzip_command = s:get_gzip_command(tarfile)
|
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
" call Decho("5: exe silent r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.shellescape(fname,1))
|
|
||||||
exe "sil! r! " . gzip_command . " -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
elseif tarfile =~# '\(\.tgz\|\.tbz\|\.txz\)'
|
||||||
|
if has("unix") && executable("file")
|
||||||
|
let filekind= system("file ".shellescape(tarfile,1))
|
||||||
|
else
|
||||||
|
let filekind= ""
|
||||||
|
endif
|
||||||
|
if filekind =~ "bzip2"
|
||||||
|
exe "sil! r! bzip2 -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
|
elseif filekind =~ "XZ"
|
||||||
|
exe "sil! r! xz -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
|
else
|
||||||
|
exe "sil! r! gzip -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
|
endif
|
||||||
|
|
||||||
elseif tarfile =~# '\.lrp$'
|
elseif tarfile =~# '\.lrp$'
|
||||||
" call Decho("6: exe silent r! cat ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
|
|
||||||
exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
exe "sil! r! cat -- ".shellescape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
elseif tarfile =~# '\.lzma$'
|
elseif tarfile =~# '\.lzma$'
|
||||||
" call Decho("7: exe silent r! lzma -d -c ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
|
|
||||||
exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
exe "sil! r! lzma -d -c -- ".shellescape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
elseif tarfile =~# '\.\(xz\|txz\)$'
|
elseif tarfile =~# '\.\(xz\|txz\)$'
|
||||||
" call Decho("3: exe silent r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp)
|
|
||||||
exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
exe "sil! r! xz --decompress --stdout -- ".shellescape(tarfile,1)." | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.shellescape(fname,1).decmp
|
||||||
else
|
else
|
||||||
if tarfile =~ '^\s*-'
|
if tarfile =~ '^\s*-'
|
||||||
@ -348,13 +383,14 @@ fun! tar#Write(fname)
|
|||||||
" sanity checks
|
" sanity checks
|
||||||
if !executable(g:tar_cmd)
|
if !executable(g:tar_cmd)
|
||||||
redraw!
|
redraw!
|
||||||
echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
|
" call Decho('***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system')
|
||||||
let &report= repkeep
|
let &report= repkeep
|
||||||
" call Dret("tar#Write")
|
" call Dret("tar#Write")
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
if !exists("*mkdir")
|
if !exists("*mkdir")
|
||||||
redraw!
|
redraw!
|
||||||
|
" call Decho("***error*** (tar#Write) sorry, mkdir() doesn't work on your system")
|
||||||
echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
|
echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
|
||||||
let &report= repkeep
|
let &report= repkeep
|
||||||
" call Dret("tar#Write")
|
" call Dret("tar#Write")
|
||||||
@ -375,6 +411,7 @@ fun! tar#Write(fname)
|
|||||||
exe "cd ".fnameescape(tmpdir)
|
exe "cd ".fnameescape(tmpdir)
|
||||||
catch /^Vim\%((\a\+)\)\=:E344/
|
catch /^Vim\%((\a\+)\)\=:E344/
|
||||||
redraw!
|
redraw!
|
||||||
|
" call Decho("***error*** (tar#Write) cannot cd to temporary directory")
|
||||||
echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
|
echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
|
||||||
let &report= repkeep
|
let &report= repkeep
|
||||||
" call Dret("tar#Write")
|
" call Dret("tar#Write")
|
||||||
@ -393,8 +430,6 @@ fun! tar#Write(fname)
|
|||||||
let tarfile = substitute(b:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
|
let tarfile = substitute(b:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
|
||||||
let fname = substitute(b:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
|
let fname = substitute(b:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
|
||||||
|
|
||||||
let gzip_command = s:get_gzip_command(tarfile)
|
|
||||||
|
|
||||||
" handle compressed archives
|
" handle compressed archives
|
||||||
if tarfile =~# '\.bz2'
|
if tarfile =~# '\.bz2'
|
||||||
call system("bzip2 -d -- ".shellescape(tarfile,0))
|
call system("bzip2 -d -- ".shellescape(tarfile,0))
|
||||||
@ -402,12 +437,12 @@ fun! tar#Write(fname)
|
|||||||
let compress= "bzip2 -- ".shellescape(tarfile,0)
|
let compress= "bzip2 -- ".shellescape(tarfile,0)
|
||||||
" call Decho("compress<".compress.">")
|
" call Decho("compress<".compress.">")
|
||||||
elseif tarfile =~# '\.gz'
|
elseif tarfile =~# '\.gz'
|
||||||
call system(gzip_command . " -d -- ".shellescape(tarfile,0))
|
call system("gzip -d -- ".shellescape(tarfile,0))
|
||||||
let tarfile = substitute(tarfile,'\.gz','','e')
|
let tarfile = substitute(tarfile,'\.gz','','e')
|
||||||
let compress= "gzip -- ".shellescape(tarfile,0)
|
let compress= "gzip -- ".shellescape(tarfile,0)
|
||||||
" call Decho("compress<".compress.">")
|
" call Decho("compress<".compress.">")
|
||||||
elseif tarfile =~# '\.tgz'
|
elseif tarfile =~# '\.tgz'
|
||||||
call system(gzip_command . " -d -- ".shellescape(tarfile,0))
|
call system("gzip -d -- ".shellescape(tarfile,0))
|
||||||
let tarfile = substitute(tarfile,'\.tgz','.tar','e')
|
let tarfile = substitute(tarfile,'\.tgz','.tar','e')
|
||||||
let compress= "gzip -- ".shellescape(tarfile,0)
|
let compress= "gzip -- ".shellescape(tarfile,0)
|
||||||
let tgz = 1
|
let tgz = 1
|
||||||
@ -427,6 +462,7 @@ fun! tar#Write(fname)
|
|||||||
|
|
||||||
if v:shell_error != 0
|
if v:shell_error != 0
|
||||||
redraw!
|
redraw!
|
||||||
|
" call Decho("***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname)
|
||||||
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
|
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -459,10 +495,11 @@ fun! tar#Write(fname)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
" delete old file from tarfile
|
" delete old file from tarfile
|
||||||
" call Decho("system(".g:tar_cmd." --delete -f ".shellescape(tarfile,0)." -- ".shellescape(fname,0).")")
|
" call Decho("system(".g:tar_cmd." ".g:tar_delfile." ".shellescape(tarfile,0)." -- ".shellescape(fname,0).")")
|
||||||
call system(g:tar_cmd." --delete -f ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
|
call system(g:tar_cmd." ".g:tar_delfile." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
|
||||||
if v:shell_error != 0
|
if v:shell_error != 0
|
||||||
redraw!
|
redraw!
|
||||||
|
" call Decho("***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname))
|
||||||
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
|
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
|
||||||
else
|
else
|
||||||
|
|
||||||
@ -471,6 +508,7 @@ fun! tar#Write(fname)
|
|||||||
call system(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
|
call system(g:tar_cmd." -".g:tar_writeoptions." ".shellescape(tarfile,0).tar_secure.shellescape(fname,0))
|
||||||
if v:shell_error != 0
|
if v:shell_error != 0
|
||||||
redraw!
|
redraw!
|
||||||
|
" call Decho("***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname))
|
||||||
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
|
echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
|
||||||
elseif exists("compress")
|
elseif exists("compress")
|
||||||
" call Decho("call system(".compress.")")
|
" call Decho("call system(".compress.")")
|
||||||
@ -486,11 +524,11 @@ fun! tar#Write(fname)
|
|||||||
if s:tblfile_{winnr()} =~ '^\a\+://'
|
if s:tblfile_{winnr()} =~ '^\a\+://'
|
||||||
" call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
|
" call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
|
||||||
let tblfile= s:tblfile_{winnr()}
|
let tblfile= s:tblfile_{winnr()}
|
||||||
1split|enew
|
1split|noswapfile enew
|
||||||
let binkeep= &l:binary
|
let binkeep= &l:binary
|
||||||
let eikeep = &ei
|
let eikeep = &ei
|
||||||
set binary ei=all
|
set binary ei=all
|
||||||
exe "e! ".fnameescape(tarfile)
|
exe "noswapfile e! ".fnameescape(tarfile)
|
||||||
call netrw#NetWrite(tblfile)
|
call netrw#NetWrite(tblfile)
|
||||||
let &ei = eikeep
|
let &ei = eikeep
|
||||||
let &l:binary = binkeep
|
let &l:binary = binkeep
|
||||||
@ -524,7 +562,7 @@ fun! tar#Diff(userfname,fname)
|
|||||||
" sets up b:tardiff_otherbuf variables so each buffer knows about the other (for closing purposes)
|
" sets up b:tardiff_otherbuf variables so each buffer knows about the other (for closing purposes)
|
||||||
diffthis
|
diffthis
|
||||||
wincmd v
|
wincmd v
|
||||||
exe "e ".fnameescape(fname)
|
exe "noswapfile e ".fnameescape(fname)
|
||||||
diffthis
|
diffthis
|
||||||
else
|
else
|
||||||
redraw!
|
redraw!
|
||||||
@ -533,6 +571,119 @@ fun! tar#Diff(userfname,fname)
|
|||||||
" call Dret("tar#Diff")
|
" call Dret("tar#Diff")
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
|
" ---------------------------------------------------------------------
|
||||||
|
" tar#Extract: extract a file from a (possibly compressed) tar archive {{{2
|
||||||
|
fun! tar#Extract()
|
||||||
|
" call Dfunc("tar#Extract()")
|
||||||
|
|
||||||
|
let repkeep= &report
|
||||||
|
set report=10
|
||||||
|
let fname= getline(".")
|
||||||
|
" call Decho("fname<".fname.">")
|
||||||
|
|
||||||
|
if !exists("g:tar_secure") && fname =~ '^\s*-\|\s\+-'
|
||||||
|
redraw!
|
||||||
|
echohl WarningMsg | echo '***warning*** (tar#BrowseSelect) rejecting tarfile member<'.fname.'> because of embedded "-"'
|
||||||
|
" call Dret('tar#BrowseSelect : rejecting tarfile member<'.fname.'> because of embedded "-"')
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
" sanity check
|
||||||
|
if fname =~ '^"'
|
||||||
|
let &report= repkeep
|
||||||
|
" call Dret("TarBrowseSelect")
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
let tarball = expand("%")
|
||||||
|
" call Decho("tarball<".tarball.">")
|
||||||
|
let tarbase = substitute(tarball,'\..*$','','')
|
||||||
|
" call Decho("tarbase<".tarbase.">")
|
||||||
|
|
||||||
|
let extractcmd= netrw#WinPath(g:tar_extractcmd)
|
||||||
|
if filereadable(tarbase.".tar")
|
||||||
|
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tar ".shellescape(fname).")")
|
||||||
|
call system(extractcmd." ".shellescape(tarbase).".tar ".shellescape(fname))
|
||||||
|
if v:shell_error != 0
|
||||||
|
echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar ".fname.": failed!" | echohl NONE
|
||||||
|
" call Decho("***error*** ".extractcmd." ".tarbase.".tar ".fname.": failed!")
|
||||||
|
else
|
||||||
|
echo "***note*** successfully extracted ".fname
|
||||||
|
endif
|
||||||
|
|
||||||
|
elseif filereadable(tarbase.".tgz")
|
||||||
|
let extractcmd= substitute(extractcmd,"-","-z","")
|
||||||
|
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tgz ".shellescape(fname).")")
|
||||||
|
call system(extractcmd." ".shellescape(tarbase).".tgz ".shellescape(fname))
|
||||||
|
if v:shell_error != 0
|
||||||
|
echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tgz ".fname.": failed!" | echohl NONE
|
||||||
|
" call Decho("***error*** ".extractcmd."t ".tarbase.".tgz ".fname.": failed!")
|
||||||
|
else
|
||||||
|
echo "***note*** successfully extracted ".fname
|
||||||
|
endif
|
||||||
|
|
||||||
|
elseif filereadable(tarbase.".tar.gz")
|
||||||
|
let extractcmd= substitute(extractcmd,"-","-z","")
|
||||||
|
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.gz ".shellescape(fname).")")
|
||||||
|
call system(extractcmd." ".shellescape(tarbase).".tar.gz ".shellescape(fname))
|
||||||
|
if v:shell_error != 0
|
||||||
|
echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.gz ".fname.": failed!" | echohl NONE
|
||||||
|
" call Decho("***error*** ".extractcmd." ".tarbase.".tar.gz ".fname.": failed!")
|
||||||
|
else
|
||||||
|
echo "***note*** successfully extracted ".fname
|
||||||
|
endif
|
||||||
|
|
||||||
|
elseif filereadable(tarbase.".tbz")
|
||||||
|
let extractcmd= substitute(extractcmd,"-","-j","")
|
||||||
|
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tbz ".shellescape(fname).")")
|
||||||
|
call system(extractcmd." ".shellescape(tarbase).".tbz ".shellescape(fname))
|
||||||
|
if v:shell_error != 0
|
||||||
|
echohl Error | echo "***error*** ".extractcmd."j ".tarbase.".tbz ".fname.": failed!" | echohl NONE
|
||||||
|
" call Decho("***error*** ".extractcmd."j ".tarbase.".tbz ".fname.": failed!")
|
||||||
|
else
|
||||||
|
echo "***note*** successfully extracted ".fname
|
||||||
|
endif
|
||||||
|
|
||||||
|
elseif filereadable(tarbase.".tar.bz2")
|
||||||
|
let extractcmd= substitute(extractcmd,"-","-j","")
|
||||||
|
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.bz2 ".shellescape(fname).")")
|
||||||
|
call system(extractcmd." ".shellescape(tarbase).".tar.bz2 ".shellescape(fname))
|
||||||
|
if v:shell_error != 0
|
||||||
|
echohl Error | echo "***error*** ".extractcmd."j ".tarbase.".tar.bz2 ".fname.": failed!" | echohl NONE
|
||||||
|
" call Decho("***error*** ".extractcmd."j ".tarbase.".tar.bz2 ".fname.": failed!")
|
||||||
|
else
|
||||||
|
echo "***note*** successfully extracted ".fname
|
||||||
|
endif
|
||||||
|
|
||||||
|
elseif filereadable(tarbase.".txz")
|
||||||
|
let extractcmd= substitute(extractcmd,"-","-J","")
|
||||||
|
" call Decho("system(".extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname).")")
|
||||||
|
call system(extractcmd." ".shellescape(tarbase).".txz ".shellescape(fname))
|
||||||
|
if v:shell_error != 0
|
||||||
|
echohl Error | echo "***error*** ".extractcmd." ".tarbase.".txz ".fname.": failed!" | echohl NONE
|
||||||
|
" call Decho("***error*** ".extractcmd." ".tarbase.".txz ".fname.": failed!")
|
||||||
|
else
|
||||||
|
echo "***note*** successfully extracted ".fname
|
||||||
|
endif
|
||||||
|
|
||||||
|
elseif filereadable(tarbase.".tar.xz")
|
||||||
|
let extractcmd= substitute(extractcmd,"-","-J","")
|
||||||
|
" call Decho("system(".extractcmd." ".shellescape(tarbase).".tar.xz ".shellescape(fname).")")
|
||||||
|
call system(extractcmd." ".shellescape(tarbase).".tar.xz ".shellescape(fname))
|
||||||
|
if v:shell_error != 0
|
||||||
|
echohl Error | echo "***error*** ".extractcmd." ".tarbase.".tar.xz ".fname.": failed!" | echohl NONE
|
||||||
|
" call Decho("***error*** ".extractcmd." ".tarbase.".tar.xz ".fname.": failed!")
|
||||||
|
else
|
||||||
|
echo "***note*** successfully extracted ".fname
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
" restore option
|
||||||
|
let &report= repkeep
|
||||||
|
|
||||||
|
" call Dret("tar#Extract")
|
||||||
|
endfun
|
||||||
|
|
||||||
" ---------------------------------------------------------------------
|
" ---------------------------------------------------------------------
|
||||||
" s:Rmdir: {{{2
|
" s:Rmdir: {{{2
|
||||||
fun! s:Rmdir(fname)
|
fun! s:Rmdir(fname)
|
||||||
@ -587,10 +738,7 @@ fun! tar#Vimuntar(...)
|
|||||||
|
|
||||||
" if necessary, decompress the tarball; then, extract it
|
" if necessary, decompress the tarball; then, extract it
|
||||||
if tartail =~ '\.tgz'
|
if tartail =~ '\.tgz'
|
||||||
let gzip_command = s:get_gzip_command(tarfile)
|
if executable("gunzip")
|
||||||
if executable(gzip_command)
|
|
||||||
silent exe "!" . gzip_command . " -d ".shellescape(tartail)
|
|
||||||
elseif executable("gunzip")
|
|
||||||
silent exe "!gunzip ".shellescape(tartail)
|
silent exe "!gunzip ".shellescape(tartail)
|
||||||
elseif executable("gzip")
|
elseif executable("gzip")
|
||||||
silent exe "!gzip -d ".shellescape(tartail)
|
silent exe "!gzip -d ".shellescape(tartail)
|
||||||
@ -628,28 +776,6 @@ fun! tar#Vimuntar(...)
|
|||||||
" call Dret("tar#Vimuntar")
|
" call Dret("tar#Vimuntar")
|
||||||
endfun
|
endfun
|
||||||
|
|
||||||
func s:get_gzip_command(file)
|
|
||||||
" Try using the "file" command to get the actual compression type, since
|
|
||||||
" there is no standard way for the naming: ".tgz", ".tbz", ".txz", etc.
|
|
||||||
" If the "file" command doesn't work fall back to just using the file name.
|
|
||||||
if a:file =~# 'z$'
|
|
||||||
let filetype = system('file ' . a:file)
|
|
||||||
if filetype =~ 'bzip2 compressed' && executable('bzip2')
|
|
||||||
return 'bzip2'
|
|
||||||
endif
|
|
||||||
if filetype =~ 'XZ compressed' && executable('xz')
|
|
||||||
return 'xz'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
if a:file =~# 'bz2$'
|
|
||||||
return 'bzip2'
|
|
||||||
endif
|
|
||||||
if a:file =~# 'xz$'
|
|
||||||
return 'xz'
|
|
||||||
endif
|
|
||||||
return 'gzip'
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
" =====================================================================
|
" =====================================================================
|
||||||
" Modelines And Restoration: {{{1
|
" Modelines And Restoration: {{{1
|
||||||
let &cpo= s:keepcpo
|
let &cpo= s:keepcpo
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
*pi_tar.txt* Nvim
|
*pi_tar.txt* For Vim version 8.2. Last change: 2020 Jan 07
|
||||||
|
|
||||||
+====================+
|
+====================+
|
||||||
| Tar File Interface |
|
| Tar File Interface |
|
||||||
+====================+
|
+====================+
|
||||||
|
|
||||||
Author: Charles E. Campbell <NdrOchip@ScampbellPfamily.AbizM>
|
Author: Charles E. Campbell <NcampObell@SdrPchip.AorgM-NOSPAM>
|
||||||
(remove NOSPAM from Campbell's email first)
|
(remove NOSPAM from Campbell's email first)
|
||||||
Copyright 2005-2012: *tar-copyright*
|
Copyright 2005-2017: *tar-copyright*
|
||||||
The VIM LICENSE (see |copyright|) applies to the files in this
|
The VIM LICENSE (see |copyright|) applies to the files in this
|
||||||
package, including tarPlugin.vim, tar.vim, and pi_tar.txt. Like
|
package, including tarPlugin.vim, tar.vim, and pi_tar.txt. Like
|
||||||
anything else that's except use "tar.vim" instead of "VIM". Like
|
anything else that's except use "tar.vim" instead of "VIM". Like
|
||||||
@ -104,48 +104,67 @@ Copyright 2005-2012: *tar-copyright*
|
|||||||
==============================================================================
|
==============================================================================
|
||||||
4. History *tar-history*
|
4. History *tar-history*
|
||||||
|
|
||||||
|
v31 Apr 02, 2017 * (klartext) reported that browsing encrypted
|
||||||
v28 Jun 23, 2011 * a few more decompression options (tbz tb2 txz)
|
files in a zip archive created unencrypted
|
||||||
v27 May 31, 2011 * moved cygwin detection before g:tar_copycmd handling
|
swap files. I am applying a similar fix
|
||||||
* inserted additional |:keepj| modifiers
|
used on zip.vim to tar.vim: new buffers
|
||||||
* changed silent to sil! (|:silent|)
|
are opened with |:noswapfile|.
|
||||||
v26 Aug 09, 2010 * uses buffer-local instead of window variables to hold
|
May 16, 2017 * When the mouse option isn't empty, the
|
||||||
tarfile name
|
leftmouse can be used to select a file
|
||||||
* inserted keepj before 0d to protect jump list
|
in the tar-file listing.
|
||||||
v25 Jun 19, 2010 * (Jan Steffens) added support for xz compression
|
v30 Apr 22, 2014 * .tgz files are ambiguous: they may have been
|
||||||
v24 Apr 07, 2009 * :Untarvim command implemented
|
compressed with either gzip or bzip2. Tar.vim
|
||||||
Sep 28, 2009 * Added lzma support
|
disambiguates by using unix's "file" command.
|
||||||
v22 Aug 08, 2008 * security fixes
|
Feb 18, 2016 * Changed =~ to =~# where appropriate
|
||||||
v16 Jun 06, 2008 * tarfile:: used instead of tarfile: when editing files
|
Feb 18, 2017 * Now also permits xz decompression
|
||||||
inside tarballs. Fixes a problem with tarballs called
|
v28 Jun 23, 2011 * a few more decompression options (tbz tb2 txz)
|
||||||
things like c:\abc.tar. (tnx to Bill McCarthy)
|
v27 May 31, 2011 * moved cygwin detection before g:tar_copycmd
|
||||||
v14 May 09, 2008 * arno caught a security bug
|
handling
|
||||||
May 28, 2008 * various security improvements. Now requires patch 299
|
* inserted additional |:keepj| modifiers
|
||||||
which provides the fnameescape() function
|
* changed silent to sil! (|:silent|)
|
||||||
May 30, 2008 * allows one to view *.gz and *.bz2 files that are in
|
v26 Aug 09, 2010 * uses buffer-local instead of window variables
|
||||||
*.tar files.
|
to hold tarfile name
|
||||||
v12 Sep 07, 2007 * &shq now used if not the empty string for g:tar_shq
|
* inserted keepj before 0d to protect jump list
|
||||||
v10 May 02, 2006 * now using "redraw then echo" to show messages, instead
|
v25 Jun 19, 2010 * (Jan Steffens) added support for xz
|
||||||
of "echo and prompt user"
|
compression
|
||||||
v9 May 02, 2006 * improved detection of masquerading as tar file
|
v24 Apr 07, 2009 * :Untarvim command implemented
|
||||||
v8 May 02, 2006 * allows editing of files that merely masquerade as tar
|
Sep 28, 2009 * Added lzma support
|
||||||
files
|
v22 Aug 08, 2008 * security fixes
|
||||||
v7 Mar 22, 2006 * work on making tar plugin work across network
|
v16 Jun 06, 2008 * tarfile:: used instead of tarfile: when
|
||||||
Mar 27, 2006 * g:tar_cmd now available for users to change the name
|
editing files inside tarballs. Fixes a
|
||||||
of the tar program to be used. By default, of course,
|
problem with tarballs called things like
|
||||||
it's "tar".
|
c:\abc.tar. (tnx to Bill McCarthy)
|
||||||
v6 Dec 21, 2005 * writing to files not in directories caused problems -
|
v14 May 09, 2008 * arno caught a security bug
|
||||||
fixed (pointed out by Christian Robinson)
|
May 28, 2008 * various security improvements. Now requires
|
||||||
v5 Nov 22, 2005 * report option workaround installed
|
patch 299 which provides the fnameescape()
|
||||||
v3 Sep 16, 2005 * handles writing files in an archive back to the
|
function
|
||||||
archive
|
May 30, 2008 * allows one to view *.gz and *.bz2 files that
|
||||||
Oct 18, 2005 * <amatch> used instead of <afile> in autocmds
|
are in *.tar files.
|
||||||
Oct 18, 2005 * handles writing to compressed archives
|
v12 Sep 07, 2007 * &shq now used if not the empty string for
|
||||||
Nov 03, 2005 * handles writing tarfiles across a network using
|
g:tar_shq
|
||||||
netrw#NetWrite()
|
v10 May 02, 2006 * now using "redraw then echo" to show messages,
|
||||||
v2 * converted to use Vim7's new autoload feature by
|
instead of "echo and prompt user"
|
||||||
Bram Moolenaar
|
v9 May 02, 2006 * improved detection of masquerading as tar file
|
||||||
v1 (original) * Michael Toren (see http://michael.toren.net/code/)
|
v8 May 02, 2006 * allows editing of files that merely masquerade
|
||||||
|
as tar files
|
||||||
|
v7 Mar 22, 2006 * work on making tar plugin work across network
|
||||||
|
Mar 27, 2006 * g:tar_cmd now available for users to change
|
||||||
|
the name of the tar program to be used. By
|
||||||
|
default, of course, it's "tar".
|
||||||
|
v6 Dec 21, 2005 * writing to files not in directories caused
|
||||||
|
problems - fixed (pointed out by
|
||||||
|
Christian Robinson)
|
||||||
|
v5 Nov 22, 2005 * report option workaround installed
|
||||||
|
v3 Sep 16, 2005 * handles writing files in an archive back to
|
||||||
|
the archive
|
||||||
|
Oct 18, 2005 * <amatch> used instead of <afile> in autocmds
|
||||||
|
Oct 18, 2005 * handles writing to compressed archives
|
||||||
|
Nov 03, 2005 * handles writing tarfiles across a network
|
||||||
|
using netrw#NetWrite()
|
||||||
|
v2 * converted to use Vim7's new autoload feature
|
||||||
|
by Bram Moolenaar
|
||||||
|
v1 (original) * Michael Toren
|
||||||
|
(see http://michael.toren.net/code/)
|
||||||
|
|
||||||
==============================================================================
|
==============================================================================
|
||||||
vim:tw=78:ts=8:noet:ft=help
|
vim:tw=78:ts=8:ft=help
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
if &cp || exists("g:loaded_tarPlugin")
|
if &cp || exists("g:loaded_tarPlugin")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let g:loaded_tarPlugin = "v29"
|
let g:loaded_tarPlugin = "v32"
|
||||||
let s:keepcpo = &cpo
|
let s:keepcpo = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
@ -39,8 +39,8 @@ augroup tar
|
|||||||
au BufReadCmd *.lrp call tar#Browse(expand("<amatch>"))
|
au BufReadCmd *.lrp call tar#Browse(expand("<amatch>"))
|
||||||
au BufReadCmd *.tar.bz2 call tar#Browse(expand("<amatch>"))
|
au BufReadCmd *.tar.bz2 call tar#Browse(expand("<amatch>"))
|
||||||
au BufReadCmd *.tar.Z call tar#Browse(expand("<amatch>"))
|
au BufReadCmd *.tar.Z call tar#Browse(expand("<amatch>"))
|
||||||
au BufReadCmd *.tgz call tar#Browse(expand("<amatch>"))
|
|
||||||
au BufReadCmd *.tbz call tar#Browse(expand("<amatch>"))
|
au BufReadCmd *.tbz call tar#Browse(expand("<amatch>"))
|
||||||
|
au BufReadCmd *.tgz call tar#Browse(expand("<amatch>"))
|
||||||
au BufReadCmd *.tar.lzma call tar#Browse(expand("<amatch>"))
|
au BufReadCmd *.tar.lzma call tar#Browse(expand("<amatch>"))
|
||||||
au BufReadCmd *.tar.xz call tar#Browse(expand("<amatch>"))
|
au BufReadCmd *.tar.xz call tar#Browse(expand("<amatch>"))
|
||||||
au BufReadCmd *.txz call tar#Browse(expand("<amatch>"))
|
au BufReadCmd *.txz call tar#Browse(expand("<amatch>"))
|
||||||
|
Loading…
Reference in New Issue
Block a user