16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
+
+
|
}
# Implementation
## Filesystem Data
namespace eval ::vfs::kitdll::data {}
set ::vfs::kitdll::data(joe) "Test\n"
set ::vfs::kitdll::data(bob) "joe"
set {::vfs::kitdll::metadata()} [list type directory ino 0 mode 0555 nlink 2 uid 0 gid 0 size 0 atime 0 mtime 0 ctime 0]
set ::vfs::kitdll::metadata(joe) [list type file ino 1 mode 0444 nlink 1 uid 0 gid 0 size 5 atime 0 mtime 0 ctime 0]
set ::vfs::kitdll::metadata(bob) [list type link ino 4 mode 0444 nlink 1 uid 0 gid 0 size 5 atime 0 mtime 0 ctime 0]
set ::vfs::kitdll::metadata(sub) [list type directory ino 2 mode 0555 nlink 1 uid 0 gid 0 size 0 atime 0 mtime 0 ctime 0]
set ::vfs::kitdll::metadata(sub/sub2) [list type directory ino 3 mode 0555 nlink 1 uid 0 gid 0 size 0 atime 0 mtime 0 ctime 0]
proc ::vfs::kitdll::data::getData {hashkey file {start 0} {end "end"}} {
if {![info exists ::vfs::kitdll::data($file)]} {
return -code error "Invalid operation"
}
|
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
-
+
+
+
+
+
+
+
|
set test [::vfs::kitdll::data::getMetadata $hashkey $relative]
}
if {![info exists test]} {
set children [list]
}
set children [list $root]
set children [list $relative]
} else {
set children [::vfs::kitdll::data::getChildren $hashkey $relative]
}
foreach child $children {
if {![string match $pattern $child]} {
continue
}
unset -nocomplain metadata
catch {
array set metadata [::vfs::kitdll::data::getMetadata $hashkey $child]
}
if {[string index $actualpath end] == "/"} {
set child "${actualpath}${child}"
} else {
set child "${actualpath}/${child}"
}
if {[string index $child end] == ""} {
set child [string range $child 0 end-1]
}
if {![info exists metadata(type)]} {
continue
}
set filetype 0
switch -- $metadata(type) {
"directory" {
set filetype [expr {$filetype | 0x04}]
}
"file" {
set filetype [expr {$filetype | 0x10}]
}
"link" {
set filetype [expr {$filetype | 0x20}]
}
default {
continue
}
}
if {($filetype & $types) != $types} {
continue
|