8 |
|
|
9 |
my $sql_filenames = q{ |
my $sql_filenames = q{ |
10 |
select |
select |
11 |
templateid as id, |
oid as id, |
12 |
namespace||'/'||name as filename, |
namespace||'/'||name||' ['||oid||']' as filename, |
13 |
length(template) as size, |
length(template) as size, |
14 |
iseditable as writable |
iseditable as writable |
15 |
from template ; |
from template ; |
18 |
my $sql_content = q{ |
my $sql_content = q{ |
19 |
select template |
select template |
20 |
from template |
from template |
21 |
where templateid = ?; |
where oid = ?; |
22 |
}; |
}; |
23 |
|
|
24 |
|
|
119 |
$f =~ s/^\E$dirname\Q//; |
$f =~ s/^\E$dirname\Q//; |
120 |
$f =~ s/^\///; |
$f =~ s/^\///; |
121 |
if ($dirname) { |
if ($dirname) { |
122 |
$out{$f}++ if (/^\E$dirname\Q/); |
$out{$f}++ if (/^\E$dirname\Q/ && $f =~ /^[^\/]+$/); |
123 |
} else { |
} else { |
124 |
$out{$f}++ if ($f =~ /^[^\/]+$/); |
$out{$f}++ if ($f =~ /^[^\/]+$/); |
125 |
} |
} |
135 |
sub e_open { |
sub e_open { |
136 |
# VFS sanity check; it keeps all the necessary state, not much to do here. |
# VFS sanity check; it keeps all the necessary state, not much to do here. |
137 |
my ($file) = filename_fixup(shift); |
my ($file) = filename_fixup(shift); |
|
print("open called\n"); |
|
138 |
return -ENOENT() unless exists($files{$file}); |
return -ENOENT() unless exists($files{$file}); |
139 |
return -EISDIR() unless exists($files{$file}{id}); |
return -EISDIR() unless exists($files{$file}{id}); |
140 |
if (!exists($files{$file}{cont})) { |
if (!exists($files{$file}{cont})) { |
141 |
$sth_content->execute($files{$file}{id}); |
$sth_content->execute($files{$file}{id}); |
142 |
($files{$file}{cont}) = $sth_content->fetchrow_array; |
$files{$file}{cont} = $sth_content->fetchrow_array; |
143 |
} |
} |
144 |
print("open ok\n"); |
print "open '$file' ",length($files{$file}{cont})," bytes\n"; |
145 |
return 0; |
return 0; |
146 |
} |
} |
147 |
|
|
148 |
sub e_read { |
sub e_read { |
149 |
# return an error numeric, or binary/text string. (note: 0 means EOF, "0" will |
# return an error numeric, or binary/text string. |
150 |
# give a byte (ascii "0") to the reading program) |
# (note: 0 means EOF, "0" will give a byte (ascii "0") |
151 |
|
# to the reading program) |
152 |
my ($file) = filename_fixup(shift); |
my ($file) = filename_fixup(shift); |
153 |
my ($buf,$off) = @_; |
my ($buf,$off) = @_; |
154 |
|
|
155 |
return -ENOENT() unless exists($files{$file}); |
return -ENOENT() unless exists($files{$file}); |
156 |
return -EINVAL() if $off > length($files{$file}{cont}); |
|
157 |
return 0 if $off == length($files{$file}{cont}); |
my $len = length($files{$file}{cont}); |
158 |
|
|
159 |
|
print "read '$file' [$len bytes] offset $off length $buf\n"; |
160 |
|
|
161 |
|
return -EINVAL() if ($off > $len); |
162 |
|
return 0 if ($off == $len); |
163 |
|
|
164 |
|
$buf = $len-$off if ($off+$buf > $len); |
165 |
|
|
166 |
return substr($files{$file}{cont},$off,$buf); |
return substr($files{$file}{cont},$off,$buf); |
167 |
} |
} |
168 |
|
|