127 "evaluate the block with a Collection of streams as first argument |
127 "evaluate the block with a Collection of streams as first argument |
128 and a dictionary containing attributes as second argument, |
128 and a dictionary containing attributes as second argument, |
129 - a collection with a stream on a single file, |
129 - a collection with a stream on a single file, |
130 - or a collection with streams on a directorie's files, but not recursive" |
130 - or a collection with streams on a directorie's files, but not recursive" |
131 |
131 |
132 |attributes fn files list| |
132 |attributes fn files list dirPath| |
133 |
133 |
134 fn := self asFilename. |
134 fn := self asFilename. |
135 files := OrderedCollection new. |
135 files := OrderedCollection new. |
136 list := OrderedCollection new. |
136 list := OrderedCollection new. |
137 attributes := self class attributes. |
137 attributes := self class attributes. |
138 |
138 |
139 fn isDirectory ifTrue:[ |
139 fn isDirectory ifTrue:[ |
|
140 dirPath := fn pathName. |
140 attributes at:#requestDirectory put:true. |
141 attributes at:#requestDirectory put:true. |
141 (DirectoryContents directoryNamed:fn pathName) filesDo:[:aFile| |
142 (DirectoryContents directoryNamed:dirPath) filesDo:[:aFile| |
142 files add:aFile |
143 files add:aFile |
143 ]. |
144 ]. |
144 ] ifFalse:[ |
145 ] ifFalse:[ |
145 attributes at:#requestDirectory put:false. |
146 attributes at:#requestDirectory put:false. |
146 files add:fn. |
147 files add:fn. |
149 fn isDirectory ifFalse:[ |bName| |
150 fn isDirectory ifFalse:[ |bName| |
150 bName := fn baseName. |
151 bName := fn baseName. |
151 (bName startsWith:'*') ifTrue:[ |
152 (bName startsWith:'*') ifTrue:[ |
152 files removeAll. |
153 files removeAll. |
153 fn := fn directory. |
154 fn := fn directory. |
|
155 dirPath := fn pathName. |
154 attributes at:#requestDirectory put:true. |
156 attributes at:#requestDirectory put:true. |
155 (DirectoryContents directoryNamed:fn pathName) filesDo:[:aFile| |
157 (DirectoryContents directoryNamed:dirPath) filesDo:[:aFile| |
156 files add:aFile |
158 files add:aFile |
157 ]. |
159 ]. |
158 ]. |
160 ]. |
159 (bName startsWith:'*.') ifTrue:[ |rest| |
161 (bName startsWith:'*.') ifTrue:[ |rest| |
160 rest := bName restAfter:$*. |
162 rest := bName restAfter:$*. |
170 baseName := aFile baseName. |
172 baseName := aFile baseName. |
171 attributes at:#fileSize put:(aFile fileSize). |
173 attributes at:#fileSize put:(aFile fileSize). |
172 attributes at:#baseName put:baseName. |
174 attributes at:#baseName put:baseName. |
173 (self pathSegements includes:baseName) ifTrue:[ |
175 (self pathSegements includes:baseName) ifTrue:[ |
174 attributes at:#uriInfo put:self. |
176 attributes at:#uriInfo put:self. |
175 ] ifFalse:[ |
177 ] ifFalse:[ |uri col| |
176 attributes at:#uriInfo put:((self copy) addComponent:baseName). |
178 uri := self copy. |
|
179 col := self pathSegements copy. |
|
180 col removeLast. |
|
181 col add:baseName. |
|
182 uri pathSegements:col. |
|
183 attributes at:#uriInfo put:uri. |
177 ]. |
184 ]. |
178 stream := aFile readStream. |
185 stream := aFile readStream. |
179 aBlock value:stream value:attributes. |
186 aBlock value:stream value:attributes. |
180 ] ensure:[ |
187 ] ensure:[ |
181 stream notNil ifTrue:[stream close] |
188 stream notNil ifTrue:[stream close] |