164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
+
-
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
|
foreach file [glob -nocomplain -tails -directory $workingDirectory *] {
if {$file in {. ..}} {
continue
}
set inputFile [file join $workingDirectory $file]
set outputFile [file join $outputDirectory [encoding convertto utf-8 $file]]
set subDirectoryName [file join $outputDirectory $file]
if {[info command ::xvfs::callback::setOutputFileName] ne ""} {
set outputFile [::xvfs::callback::setOutputFileName $file $workingDirectory $inputFile $outputDirectory $outputFile]
if {$outputFile eq "/"} {
continue
}
}
unset -nocomplain fileInfo
catch {
file lstat $inputFile fileInfo
}
if {![info exists fileInfo]} {
puts stderr "warning: Unable to access $inputFile, skipping"
}
lappend children [file tail $file]
if {$fileInfo(type) eq "directory"} {
lappend subDirectories $outputFile
lappend subDirectories $subDirectoryName
continue
}
processFile $fsName $inputFile $outputFile [array get fileInfo]
lappend outputFiles $outputFile
}
foreach subDirectory $subDirectories {
lappend outputFiles {*}[processDirectory $fsName $directory $subDirectory]
}
set inputFile $directory
set outputFile $outputDirectory
if {[info command ::xvfs::callback::setOutputFileName] ne ""} {
set outputFile [::xvfs::callback::setOutputFileName $directory $directory $inputFile $outputDirectory $outputFile]
}
if {$outputFile ne "/"} {
unset -nocomplain fileInfo
file stat $inputFile fileInfo
set children [list]
set outputFileLen [string length $outputFile]
foreach child $outputFiles {
if {[string range /$child 0 $outputFileLen] eq "/${outputFile}"} {
set child [string trimleft [string range $child $outputFileLen end] /]
if {![string match "*/*" $child]} {
lappend children $child
}
}
}
set fileInfo(children) $children
processFile $fsName $inputFile $outputFile [array get fileInfo]
lappend outputFiles $outputFile
}
if {$isTopLevel} {
|