annotate runtime/autoload/zip.vim @ 625:81fe2ccc1207 v7.0179

updated for version 7.0179
author vimboss
date Thu, 12 Jan 2006 23:22:24 +0000
parents bd2fe62c9d77
children 95dac6af3b3a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
1 " zip.vim: Handles browsing zipfiles
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
2 " AUTOLOAD PORTION
623
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
3 " Date: Dec 21, 2005
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
4 " Version: 6
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
5 " Maintainer: Charles E Campbell, Jr <drchipNOSPAM at campbellfamily dot biz>
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
6 " License: Vim License (see vim's :help license)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
7 " Copyright: Copyright (C) 2005 Charles E. Campbell, Jr. {{{1
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
8 " Permission is hereby granted to use and distribute this code,
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
9 " with or without modifications, provided that this copyright
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
10 " notice is copied with it. Like anything else that's free,
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
11 " zipPlugin.vim is provided *as is* and comes with no warranty
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
12 " of any kind, either expressed or implied. By using this
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
13 " plugin, you agree that in no event will the copyright
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
14 " holder be liable for any damages resulting from the use
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
15 " of this software.
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
16
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
17 " ---------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
18 " Initialization: {{{1
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
19 let s:keepcpo= &cpo
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
20 set cpo&vim
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
21 if exists("g:loaded_zip")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
22 finish
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
23 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
24
623
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
25 let g:loaded_zip= "v6"
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
26
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
27 " ----------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
28 " Functions: {{{1
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
29 " ----------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
30
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
31 " ---------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
32 " zip#Browse: {{{2
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
33 fun! zip#Browse(zipfile)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
34 " call Dfunc("zip#Browse(zipfile<".a:zipfile.">)")
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
35 let repkeep= &report
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
36 set report=10
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
37
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
38 " sanity checks
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
39 if !executable("unzip")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
40 echohl Error | echo "***error*** (zip#Browse) unzip not available on your system"
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
41 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
42 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
43 " call Dret("zip#Browse")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
44 return
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
45 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
46 if !filereadable(a:zipfile)
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
47 if a:zipfile !~# '^\a\+://'
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
48 " if its an url, don't complain, let url-handlers such as vim do its thing
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
49 echohl Error | echo "***error*** (zip#Browse) File not readable<".a:zipfile.">" | echohl None
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
50 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
51 endif
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
52 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
53 " call Dret("zip#Browse : file<".a:zipfile."> not readable")
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
54 return
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
55 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
56 if &ma != 1
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
57 set ma
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
58 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
59 let w:zipfile= a:zipfile
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
60
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
61 setlocal noswapfile
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
62 setlocal buftype=nofile
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
63 setlocal bufhidden=hide
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
64 setlocal nobuflisted
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
65 setlocal nowrap
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
66 set ft=tar
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
67
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
68 " give header
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
69 exe "$put ='".'\"'." zip.vim version ".g:loaded_zip."'"
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
70 exe "$put ='".'\"'." Browsing zipfile ".a:zipfile."'"
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
71 exe "$put ='".'\"'." Select a file with cursor and press ENTER"."'"
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
72 $put =''
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
73 0d
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
74 $
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
75
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
76 exe "silent r! unzip -l ".a:zipfile
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
77 $d
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
78 silent 4,$v/^\s\+\d\+\s\{0,5}\d/d
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
79 silent 4,$s/^\%(.*\)\s\+\(\S\)/\1/
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
80
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
81 setlocal noma nomod ro
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
82 noremap <silent> <buffer> <cr> :call <SID>ZipBrowseSelect()<cr>
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
83
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
84 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
85 " call Dret("zip#Browse")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
86 endfun
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
87
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
88 " ---------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
89 " ZipBrowseSelect: {{{2
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
90 fun! s:ZipBrowseSelect()
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
91 " call Dfunc("ZipBrowseSelect() zipfile<".w:zipfile."> curfile<".expand("%").">")
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
92 let repkeep= &report
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
93 set report=10
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
94 let fname= getline(".")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
95
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
96 " sanity check
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
97 if fname =~ '^"'
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
98 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
99 " call Dret("ZipBrowseSelect")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
100 return
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
101 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
102 if fname =~ '/$'
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
103 echohl Error | echo "***error*** (zip#Browse) Please specify a file, not a directory" | echohl None
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
104 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
105 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
106 " call Dret("ZipBrowseSelect")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
107 return
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
108 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
109
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
110 " call Decho("fname<".fname.">")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
111
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
112 " get zipfile to the new-window
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
113 let zipfile= substitute(w:zipfile,'.zip$','','e')
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
114 let curfile= expand("%")
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
115
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
116 new
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
117 wincmd _
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
118 let s:zipfile_{winnr()}= curfile
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
119 exe "e zipfile:".zipfile.':'.fname
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
120 filetype detect
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
121
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
122 let &report= repkeep
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
123 " call Dret("ZipBrowseSelect : s:zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
124 endfun
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
125
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
126 " ---------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
127 " zip#Read: {{{2
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
128 fun! zip#Read(fname,mode)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
129 " call Dfunc("zip#Read(fname<".a:fname.">,mode=".a:mode.")")
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
130 let repkeep= &report
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
131 set report=10
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
132
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
133 let zipfile = substitute(a:fname,'zipfile:\(.\{-}\):.*$','\1','')
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
134 let fname = substitute(a:fname,'zipfile:.\{-}:\(.*\)$','\1','')
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
135 " call Decho("zipfile<".zipfile."> fname<".fname.">")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
136
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
137 exe "r! unzip -p ".zipfile." ".fname
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
138
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
139 " cleanup
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
140 0d
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
141 set nomod
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
142
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
143 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
144 " call Dret("zip#Read")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
145 endfun
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
146
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
147 " ---------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
148 " zip#Write: {{{2
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
149 fun! zip#Write(fname)
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
150 " call Dfunc("zip#Write(fname<".a:fname.") zipfile_".winnr()."<".s:zipfile_{winnr()}.">")
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
151 let repkeep= &report
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
152 set report=10
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
153
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
154 " sanity checks
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
155 if !executable("zip")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
156 echohl Error | echo "***error*** (zip#Write) sorry, your system doesn't appear to have the zip pgm" | echohl None
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
157 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
158 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
159 " call Dret("zip#Write")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
160 return
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
161 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
162 if !exists("*mkdir")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
163 echohl Error | echo "***error*** (zip#Write) sorry, mkdir() doesn't work on your system" | echohl None
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
164 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
165 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
166 " call Dret("zip#Write")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
167 return
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
168 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
169
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
170 let curdir= getcwd()
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
171 let tmpdir= tempname()
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
172 " call Decho("orig tempname<".tmpdir.">")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
173 if tmpdir =~ '\.'
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
174 let tmpdir= substitute(tmpdir,'\.[^.]*$','','e')
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
175 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
176 " call Decho("tmpdir<".tmpdir.">")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
177 call mkdir(tmpdir,"p")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
178
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
179 " attempt to change to the indicated directory
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
180 try
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
181 exe "cd ".escape(tmpdir,' \')
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
182 catch /^Vim\%((\a\+)\)\=:E344/
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
183 echohl Error | echo "***error*** (zip#Write) cannot cd to temporary directory" | Echohl None
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
184 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
185 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
186 " call Dret("zip#Write")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
187 return
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
188 endtry
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
189 " call Decho("current directory now: ".getcwd())
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
190
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
191 " place temporary files under .../_ZIPVIM_/
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
192 if isdirectory("_ZIPVIM_")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
193 call s:Rmdir("_ZIPVIM_")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
194 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
195 call mkdir("_ZIPVIM_")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
196 cd _ZIPVIM_
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
197 " call Decho("current directory now: ".getcwd())
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
198
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
199 let zipfile = substitute(a:fname,'zipfile:\(.\{-}\):.*$','\1','')
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
200 let fname = substitute(a:fname,'zipfile:.\{-}:\(.*\)$','\1','')
623
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
201
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
202 if fname =~ '/'
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
203 let dirpath = substitute(fname,'/[^/]\+$','','e')
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
204 if executable("cygpath")
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
205 let dirpath = substitute(system("cygpath ".dirpath),'\n','','e')
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
206 endif
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
207 call mkdir(dirpath,"p")
bd2fe62c9d77 updated for version 7.0178
vimboss
parents: 568
diff changeset
208 endif
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
209 if zipfile !~ '/'
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
210 let zipfile= curdir.'/'.zipfile
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
211 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
212 " call Decho("zipfile<".zipfile."> fname<".fname.">")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
213
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
214 exe "w! ".fname
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
215 if executable("cygpath")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
216 let zipfile = substitute(system("cygpath ".zipfile),'\n','','e')
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
217 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
218
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
219 " call Decho("zip -u ".zipfile.".zip ".fname)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
220 call system("zip -u ".zipfile.".zip ".fname)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
221 if v:shell_error != 0
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
222 echohl Error | echo "***error*** (zip#Write) sorry, unable to update ".zipfile." with ".fname | echohl None
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
223 call inputsave()|call input("Press <cr> to continue")|call inputrestore()
557
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
224
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
225 elseif s:zipfile_{winnr()} =~ '^\a\+://'
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
226 " support writing zipfiles across a network
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
227 let netzipfile= s:zipfile_{winnr()}
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
228 " call Decho("handle writing <".zipfile.".zip> across network as <".netzipfile.">")
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
229 1split|enew
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
230 let binkeep= &binary
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
231 let eikeep = &ei
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
232 set binary ei=all
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
233 exe "e! ".zipfile.".zip"
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
234 call netrw#NetWrite(netzipfile)
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
235 let &ei = eikeep
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
236 let &binary = binkeep
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
237 q!
862863033fdd updated for version 7.0158
vimboss
parents: 530
diff changeset
238 unlet s:zipfile_{winnr()}
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
239 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
240
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
241 " cleanup and restore current directory
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
242 cd ..
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
243 call s:Rmdir("_ZIPVIM_")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
244 exe "cd ".escape(curdir,' \')
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
245 setlocal nomod
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
246
568
db92c5cc4f66 updated for version 7.0161
vimboss
parents: 557
diff changeset
247 let &report= repkeep
530
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
248 " call Dret("zip#Write")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
249 endfun
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
250
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
251 " ---------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
252 " Rmdir: {{{2
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
253 fun! s:Rmdir(fname)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
254 " call Dfunc("Rmdir(fname<".a:fname.">)")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
255 if has("unix")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
256 call system("/bin/rm -rf ".a:fname)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
257 elseif has("win32") || has("win95") || has("win64") || has("win16")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
258 if &shell =~? "sh$"
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
259 call system("/bin/rm -rf ".a:fname)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
260 else
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
261 call system("del /S ".a:fname)
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
262 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
263 endif
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
264 " call Dret("Rmdir")
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
265 endfun
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
266
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
267 " ------------------------------------------------------------------------
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
268 " Modelines And Restoration: {{{1
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
269 let &cpo= s:keepcpo
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
270 unlet s:keepcpo
339999b511a0 updated for version 7.0148
vimboss
parents:
diff changeset
271 " vim:ts=8 fdm=marker