annotate runtime/autoload/tar.vim @ 1884:3dd986bfef63 v7.2.181

updated for version 7.2-181
author vimboss
date Sun, 17 May 2009 14:24:23 +0000
parents 5232b9862f23
children 7bc41231fbc7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
1 " tar.vim: Handles browsing tarfiles
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
2 " AUTOLOAD PORTION
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
3 " Date: Aug 08, 2008
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
4 " Version: 23 + modifications by Bram
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
5 " Maintainer: Charles E Campbell, Jr <NdrOchip@ScampbellPfamily.AbizM-NOSPAM>
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
6 " License: Vim License (see vim's :help license)
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
7 "
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
8 " Contains many ideas from Michael Toren's <tar.vim>
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
9 "
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
10 " Copyright: Copyright (C) 2005-2008 Charles E. Campbell, Jr. {{{1
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
11 " Permission is hereby granted to use and distribute this code,
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
12 " with or without modifications, provided that this copyright
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
13 " notice is copied with it. Like anything else that's free,
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
14 " tar.vim and tarPlugin.vim are provided *as is* and comes
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
15 " with no warranty of any kind, either expressed or implied.
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
16 " By using this plugin, you agree that in no event will the
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
17 " copyright holder be liable for any damages resulting from
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
18 " the use of this software.
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
19
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
20 " ---------------------------------------------------------------------
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
21 " Load Once: {{{1
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
22 let s:keepcpo= &cpo
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
23 set cpo&vim
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
24 if &cp || exists("g:loaded_tar") || v:version < 700
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
25 finish
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
26 endif
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
27 let g:loaded_tar= "v23b"
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
28 "call Decho("loading autoload/tar.vim")
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
29 if v:version < 701 || (v:version == 701 && !has("patch299"))
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
30 echoerr "(autoload/tar.vim) need vim v7.1 with patchlevel 299"
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
31 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
32
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
33 " ---------------------------------------------------------------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
34 " Default Settings: {{{1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
35 if !exists("g:tar_browseoptions")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
36 let g:tar_browseoptions= "Ptf"
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
37 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
38 if !exists("g:tar_readoptions")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
39 let g:tar_readoptions= "OPxf"
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
40 endif
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
41 if !exists("g:tar_cmd")
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
42 let g:tar_cmd= "tar"
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
43 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
44 if !exists("g:tar_writeoptions")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
45 let g:tar_writeoptions= "uf"
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
46 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
47
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
48 if !exists("g:netrw_cygwin")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
49 if has("win32") || has("win95") || has("win64") || has("win16")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
50 if &shell =~ '\%(\<bash\>\|\<zsh\>\)\%(\.exe\)\=$'
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
51 let g:netrw_cygwin= 1
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
52 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
53 let g:netrw_cygwin= 0
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
54 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
55 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
56 let g:netrw_cygwin= 0
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
57 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
58 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
59
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
60 " set up shell quoting character
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
61 if !exists("g:tar_shq")
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
62 if exists("&shq") && &shq != ""
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
63 let g:tar_shq= &shq
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
64 elseif has("win32") || has("win95") || has("win64") || has("win16")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
65 if exists("g:netrw_cygwin") && g:netrw_cygwin
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
66 let g:tar_shq= "'"
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
67 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
68 let g:tar_shq= '"'
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
69 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
70 else
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
71 let g:tar_shq= "'"
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
72 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
73 " call Decho("g:tar_shq<".g:tar_shq.">")
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
74 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
75
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
76 " ----------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
77 " Functions: {{{1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
78 " ----------------
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
79
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
80 " ---------------------------------------------------------------------
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
81 " tar#Browse: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
82 fun! tar#Browse(tarfile)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
83 " call Dfunc("tar#Browse(tarfile<".a:tarfile.">)")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
84 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
85 set report=10
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
86
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
87 " sanity checks
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
88 if !executable(g:tar_cmd)
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
89 redraw!
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
90 echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
91 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
92 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
93 " call Dret("tar#Browse")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
94 return
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
95 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
96 if !filereadable(a:tarfile)
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
97 " call Decho('a:tarfile<'.a:tarfile.'> not filereadable')
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
98 if a:tarfile !~# '^\a\+://'
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
99 " if its an url, don't complain, let url-handlers such as vim do its thing
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
100 redraw!
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
101 echohl Error | echo "***error*** (tar#Browse) File not readable<".a:tarfile.">" | echohl None
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
102 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
103 endif
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
104 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
105 " call Dret("tar#Browse : file<".a:tarfile."> not readable")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
106 return
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
107 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
108 if &ma != 1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
109 set ma
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
110 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
111 let w:tarfile= a:tarfile
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
112
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
113 setlocal noswapfile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
114 setlocal buftype=nofile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
115 setlocal bufhidden=hide
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
116 setlocal nobuflisted
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
117 setlocal nowrap
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
118 set ft=tar
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
119
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
120 " give header
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
121 " call Decho("printing header")
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
122 let lastline= line("$")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
123 call setline(lastline+1,'" tar.vim version '.g:loaded_tar)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
124 call setline(lastline+2,'" Browsing tarfile '.a:tarfile)
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
125 call setline(lastline+3,'" Select a file with cursor and press ENTER')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
126 $put =''
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
127 0d
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
128 $
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
129
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
130 let tarfile= a:tarfile
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
131 if has("win32") && executable("cygpath")
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
132 " assuming cygwin
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
133 let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
134 endif
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
135 let curlast= line("$")
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
136 if tarfile =~# '\.\(gz\|tgz\)$'
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
137 " call Decho("1: exe silent r! gzip -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
138 exe "silent r! gzip -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
139 elseif tarfile =~# '\.lrp'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
140 " call Decho("2: exe silent r! cat -- ".s:Escape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - ")
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
141 exe "silent r! cat -- ".s:Escape(tarfile,1)."|gzip -d -c -|".g:tar_cmd." -".g:tar_browseoptions." - "
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
142 elseif tarfile =~# '\.bz2$'
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
143 " call Decho("3: exe silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - ")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
144 exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)." | ".g:tar_cmd." -".g:tar_browseoptions." - "
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
145 else
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
146 if tarfile =~ '^\s*-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
147 " A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
148 let tarfile = substitute(tarfile, '-', './-', '')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
149 endif
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
150 " call Decho("4: exe silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile,1))
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
151 exe "silent r! ".g:tar_cmd." -".g:tar_browseoptions." ".s:Escape(tarfile,1)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
152 endif
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
153 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
154 redraw!
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
155 echohl WarningMsg | echo "***warning*** (tar#Browse) please check your g:tar_browseoptions<".g:tar_browseoptions.">"
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
156 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
157 " call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
158 return
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
159 endif
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
160 if line("$") == curlast || ( line("$") == (curlast + 1) && getline("$") =~ '\c\%(warning\|error\|inappropriate\|unrecognized\)')
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
161 redraw!
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
162 echohl WarningMsg | echo "***warning*** (tar#Browse) ".a:tarfile." doesn't appear to be a tar file" | echohl None
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
163 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
164 silent %d
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
165 let eikeep= &ei
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
166 set ei=BufReadCmd,FileReadCmd
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
167 exe "r ".fnameescape(a:tarfile)
857
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
168 let &ei= eikeep
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
169 1d
b933657f7c9d updated for version 7.0g01
vimboss
parents: 819
diff changeset
170 " call Dret("tar#Browse : a:tarfile<".a:tarfile.">")
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
171 return
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
172 endif
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
173
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
174 setlocal noma nomod ro
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
175 noremap <silent> <buffer> <cr> :call <SID>TarBrowseSelect()<cr>
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
176
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
177 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
178 " call Dret("tar#Browse : w:tarfile<".w:tarfile.">")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
179 endfun
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
180
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
181 " ---------------------------------------------------------------------
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
182 " TarBrowseSelect: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
183 fun! s:TarBrowseSelect()
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
184 " call Dfunc("TarBrowseSelect() w:tarfile<".w:tarfile."> curfile<".expand("%").">")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
185 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
186 set report=10
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
187 let fname= getline(".")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
188 " call Decho("fname<".fname.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
189
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
190 if !exists("g:tar_secure") && fname =~ '^\s*-\|\s\+-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
191 redraw!
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
192 echohl WarningMsg | echo '***error*** (tar#BrowseSelect) rejecting tarfile member<'.fname.'> because of embedded "-"; See :help tar-options'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
193 " call Dret('tar#BrowseSelect : rejecting tarfile member<'.fname.'> because of embedded "-"')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
194 return
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
195 endif
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
196
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
197 " sanity check
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
198 if fname =~ '^"'
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
199 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
200 " call Dret("TarBrowseSelect")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
201 return
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
202 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
203
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
204 " about to make a new window, need to use w:tarfile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
205 let tarfile= w:tarfile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
206 let curfile= expand("%")
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
207 if has("win32") && executable("cygpath")
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
208 " assuming cygwin
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
209 let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
210 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
211
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
212 new
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
213 if !exists("g:tar_nomax") || g:tar_nomax == 0
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
214 wincmd _
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
215 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
216 let s:tblfile_{winnr()}= curfile
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
217 call tar#Read("tarfile:".tarfile.'::'.fname,1)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
218 filetype detect
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
219
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
220 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
221 " call Dret("TarBrowseSelect : s:tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
222 endfun
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
223
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
224 " ---------------------------------------------------------------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
225 " tar#Read: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
226 fun! tar#Read(fname,mode)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
227 " call Dfunc("tar#Read(fname<".a:fname.">,mode=".a:mode.")")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
228 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
229 set report=10
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
230 let tarfile = substitute(a:fname,'tarfile:\(.\{-}\)::.*$','\1','')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
231 let fname = substitute(a:fname,'tarfile:.\{-}::\(.*\)$','\1','')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
232 if has("win32") && executable("cygpath")
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
233 " assuming cygwin
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
234 let tarfile=substitute(system("cygpath -u ".s:Escape(tarfile,0)),'\n$','','e')
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
235 endif
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
236 " call Decho("tarfile<".tarfile.">")
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
237 " call Decho("fname<".fname.">")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
238
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
239 if fname =~ '\.gz$' && executable("zcat")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
240 let decmp= "|zcat"
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
241 let doro = 1
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
242 elseif fname =~ '\.bz2$' && executable("bzcat")
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
243 let decmp= "|bzcat"
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
244 let doro = 1
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
245 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
246 let decmp=""
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
247 let doro = 0
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
248 if fname =~ '\.gz$\|\.bz2$\|\.Z$\|\.zip$'
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
249 setlocal bin
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
250 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
251 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
252
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
253 if exists("g:tar_secure")
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
254 let tar_secure= " -- "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
255 else
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
256 let tar_secure= " "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
257 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
258 if tarfile =~# '\.\(gz\|tgz\)$'
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
259 " call Decho("5: exe silent r! gzip -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd.' -'.g:tar_readoptions.' - '.tar_secure.s:Escape(fname,1))
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
260 exe "silent r! gzip -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
261 elseif tarfile =~# '\.lrp$'
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
262 " call Decho("6: exe silent r! cat ".s:Escape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp)
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
263 exe "silent r! cat -- ".s:Escape(tarfile,1)." | gzip -d -c - | ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
624
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
264 elseif tarfile =~# '\.bz2$'
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
265 " call Decho("7: exe silent r! bzip2 -d -c ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp)
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
266 exe "silent r! bzip2 -d -c -- ".s:Escape(tarfile,1)."| ".g:tar_cmd." -".g:tar_readoptions." - ".tar_secure.s:Escape(fname,1).decmp
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
267 else
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
268 if tarfile =~ '^\s*-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
269 " A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
270 let tarfile = substitute(tarfile, '-', './-', '')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
271 endif
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
272 " call Decho("8: exe silent r! ".g:tar_cmd." -".g:tar_readoptions." "s:Escape(tarfile,1).tar_secure..s:Escape(fname,1).decmp)
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
273 exe "silent r! ".g:tar_cmd." -".g:tar_readoptions." ".s:Escape(tarfile,1).tar_secure.s:Escape(fname,1).decmp
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
274 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
275
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
276 if doro
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
277 " because the reverse process of compressing changed files back into the tarball is not currently supported
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
278 setlocal ro
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
279 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
280
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
281 let w:tarfile= a:fname
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
282 exe "file tarfile::".fnameescape(fname)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
283
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
284 " cleanup
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
285 0d
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
286 set nomod
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
287
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
288 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
289 " call Dret("tar#Read : w:tarfile<".w:tarfile.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
290 endfun
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
291
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
292 " ---------------------------------------------------------------------
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
293 " tar#Write: {{{2
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
294 fun! tar#Write(fname)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
295 " call Dfunc("tar#Write(fname<".a:fname.">) w:tarfile<".w:tarfile."> tblfile_".winnr()."<".s:tblfile_{winnr()}.">")
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
296 let repkeep= &report
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
297 set report=10
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
298
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
299 if !exists("g:tar_secure") && a:fname =~ '^\s*-\|\s\+-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
300 redraw!
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
301 echohl WarningMsg | echo '***error*** (tar#Write) rejecting tarfile member<'.a:fname.'> because of embedded "-"; See :help tar-options'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
302 " call Dret('tar#Write : rejecting tarfile member<'.fname.'> because of embedded "-"')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
303 return
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
304 endif
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
305
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
306 " sanity checks
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
307 if !executable(g:tar_cmd)
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
308 redraw!
819
23f82b5d2814 updated for version 7.0c10
vimboss
parents: 624
diff changeset
309 echohl Error | echo '***error*** (tar#Browse) "'.g:tar_cmd.'" not available on your system'
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
310 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
311 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
312 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
313 return
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
314 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
315 if !exists("*mkdir")
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
316 redraw!
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
317 echohl Error | echo "***error*** (tar#Write) sorry, mkdir() doesn't work on your system" | echohl None
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
318 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
319 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
320 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
321 return
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
322 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
323
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
324 let curdir= getcwd()
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
325 let tmpdir= tempname()
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
326 " call Decho("orig tempname<".tmpdir.">")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
327 if tmpdir =~ '\.'
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
328 let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
329 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
330 " call Decho("tmpdir<".tmpdir.">")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
331 call mkdir(tmpdir,"p")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
332
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
333 " attempt to change to the indicated directory
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
334 try
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
335 exe "cd ".fnameescape(tmpdir)
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
336 catch /^Vim\%((\a\+)\)\=:E344/
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
337 redraw!
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
338 echohl Error | echo "***error*** (tar#Write) cannot cd to temporary directory" | Echohl None
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
339 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
340 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
341 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
342 return
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
343 endtry
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
344 " call Decho("current directory now: ".getcwd())
446
7472c565592a updated for version 7.0117
vimboss
parents:
diff changeset
345
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
346 " place temporary files under .../_ZIPVIM_/
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
347 if isdirectory("_ZIPVIM_")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
348 call s:Rmdir("_ZIPVIM_")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
349 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
350 call mkdir("_ZIPVIM_")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
351 cd _ZIPVIM_
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
352 " call Decho("current directory now: ".getcwd())
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
353
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
354 let tarfile = substitute(w:tarfile,'tarfile:\(.\{-}\)::.*$','\1','')
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
355 let fname = substitute(w:tarfile,'tarfile:.\{-}::\(.*\)$','\1','')
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
356
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
357 " handle compressed archives
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
358 if tarfile =~# '\.gz'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
359 call system("gzip -d -- ".s:Escape(tarfile,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
360 let tarfile = substitute(tarfile,'\.gz','','e')
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
361 let compress= "gzip -- ".s:Escape(tarfile,0)
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
362 " call Decho("compress<".compress.">")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
363 elseif tarfile =~# '\.tgz'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
364 call system("gzip -d -- ".s:Escape(tarfile,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
365 let tarfile = substitute(tarfile,'\.tgz','.tar','e')
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
366 let compress= "gzip -- ".s:Escape(tarfile,0)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
367 let tgz = 1
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
368 " call Decho("compress<".compress.">")
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
369 elseif tarfile =~# '\.bz2'
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
370 call system("bzip2 -d -- ".s:Escape(tarfile,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
371 let tarfile = substitute(tarfile,'\.bz2','','e')
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
372 let compress= "bzip2 -- ".s:Escape(tarfile,0)
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
373 " call Decho("compress<".compress.">")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
374 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
375 " call Decho("tarfile<".tarfile.">")
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
376
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
377 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
378 redraw!
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
379 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".tarfile." with ".fname | echohl None
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
380 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
381 else
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
382
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
383 " call Decho("tarfile<".tarfile."> fname<".fname.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
384
624
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
385 if fname =~ '/'
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
386 let dirpath = substitute(fname,'/[^/]\+$','','e')
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
387 if executable("cygpath")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
388 let dirpath = substitute(system("cygpath ".s:Escape(dirpath, 0)),'\n','','e')
624
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
389 endif
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
390 call mkdir(dirpath,"p")
91e7d4a7b3b0 updated for version 7.0178
vimboss
parents: 569
diff changeset
391 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
392 if tarfile !~ '/'
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
393 let tarfile= curdir.'/'.tarfile
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
394 endif
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
395 if tarfile =~ '^\s*-'
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
396 " A file name starting with a dash may be taken as an option. Prepend ./ to avoid that.
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
397 let tarfile = substitute(tarfile, '-', './-', '')
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
398 endif
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
399 " call Decho("tarfile<".tarfile."> fname<".fname.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
400
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
401 if exists("g:tar_secure")
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
402 let tar_secure= " -- "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
403 else
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
404 let tar_secure= " "
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
405 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
406 exe "w! ".fnameescape(fname)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
407 if executable("cygpath")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
408 let tarfile = substitute(system("cygpath ".s:Escape(tarfile,0)),'\n','','e')
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
409 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
410
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
411 " delete old file from tarfile
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
412 " call Decho("system(".g:tar_cmd." --delete -f ".s:Escape(tarfile,0)." -- ".s:Escape(fname,0).")")
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
413 call system(g:tar_cmd." --delete -f ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
414 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
415 redraw!
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
416 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
417 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
418 else
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
419
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
420 " update tarfile with new file
1702
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
421 " call Decho(g:tar_cmd." -".g:tar_writeoptions." ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
5232b9862f23 updated for version 7.2-000
vimboss
parents: 1698
diff changeset
422 call system(g:tar_cmd." -".g:tar_writeoptions." ".s:Escape(tarfile,0).tar_secure.s:Escape(fname,0))
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
423 if v:shell_error != 0
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
424 redraw!
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
425 echohl Error | echo "***error*** (tar#Write) sorry, unable to update ".fnameescape(tarfile)." with ".fnameescape(fname) | echohl None
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 857
diff changeset
426 " call inputsave()|call input("Press <cr> to continue")|call inputrestore()
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
427 elseif exists("compress")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
428 " call Decho("call system(".compress.")")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
429 call system(compress)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
430 if exists("tgz")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
431 " call Decho("rename(".tarfile.".gz,".substitute(tarfile,'\.tar$','.tgz','e').")")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
432 call rename(tarfile.".gz",substitute(tarfile,'\.tar$','.tgz','e'))
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
433 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
434 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
435 endif
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
436
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
437 " support writing tarfiles across a network
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
438 if s:tblfile_{winnr()} =~ '^\a\+://'
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
439 " call Decho("handle writing <".tarfile."> across network to <".s:tblfile_{winnr()}.">")
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
440 let tblfile= s:tblfile_{winnr()}
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
441 1split|enew
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
442 let binkeep= &binary
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
443 let eikeep = &ei
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
444 set binary ei=all
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
445 exe "e! ".fnameescape(tarfile)
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
446 call netrw#NetWrite(tblfile)
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
447 let &ei = eikeep
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
448 let &binary = binkeep
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
449 q!
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
450 unlet s:tblfile_{winnr()}
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
451 endif
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
452 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
453
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
454 " cleanup and restore current directory
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
455 cd ..
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
456 call s:Rmdir("_ZIPVIM_")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
457 exe "cd ".fnameescape(curdir)
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
458 setlocal nomod
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
459
569
bdbdec22a225 updated for version 7.0161
vimboss
parents: 557
diff changeset
460 let &report= repkeep
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
461 " call Dret("tar#Write")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
462 endfun
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
463
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
464 " ---------------------------------------------------------------------
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
465 " Rmdir: {{{2
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
466 fun! s:Rmdir(fname)
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
467 " call Dfunc("Rmdir(fname<".a:fname.">)")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
468 if has("unix")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
469 call system("/bin/rm -rf -- ".s:Escape(a:fname,0))
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
470 elseif has("win32") || has("win95") || has("win64") || has("win16")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
471 if &shell =~? "sh$"
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
472 call system("/bin/rm -rf -- ".s:Escape(a:fname,0))
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
473 else
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
474 call system("del /S ".s:Escape(a:fname,0))
527
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
475 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
476 endif
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
477 " call Dret("Rmdir")
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
478 endfun
93a822c9e3d2 updated for version 7.0147
vimboss
parents: 446
diff changeset
479
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
480 " ---------------------------------------------------------------------
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
481 " s:Escape: {{{2
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
482 fun s:Escape(name,isfilt)
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
483 " shellescape() was added by patch 7.0.111
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
484 if exists("*shellescape")
1668
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
485 if a:isfilt
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
486 let qnameq= shellescape(a:name,1)
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
487 else
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
488 let qnameq= shellescape(a:name)
0b796e045c42 updated for version 7.2b-000
vimboss
parents: 1624
diff changeset
489 endif
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
490 else
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
491 let qnameq= g:tar_shq . a:name . g:tar_shq
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
492 endif
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
493 return qnameq
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
494 endfun
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
495
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
496 " ---------------------------------------------------------------------
557
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
497 " Modelines And Restoration: {{{1
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
498 let &cpo= s:keepcpo
862863033fdd updated for version 7.0158
vimboss
parents: 527
diff changeset
499 unlet s:keepcpo
1624
18ee39301b82 updated for version 7.2a
vimboss
parents: 1125
diff changeset
500 " vim:ts=8 fdm=marker