/[fuse_dbi]/fuse-couchdb/DBI.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /fuse-couchdb/DBI.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2 by dpavlin, Wed Aug 4 09:03:05 2004 UTC revision 3 by dpavlin, Wed Aug 4 09:25:31 2004 UTC
# Line 8  use strict; Line 8  use strict;
8    
9  my $sql_filenames = q{  my $sql_filenames = q{
10          select          select
11                  templateid as id,                  oid as id,
12                  namespace||'/'||name||' ['||templateid||']' 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 ;
# Line 18  my $sql_filenames = q{ Line 18  my $sql_filenames = q{
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    
# Line 135  sub e_getdir { Line 135  sub e_getdir {
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    

Legend:
Removed from v.2  
changed lines
  Added in v.3

  ViewVC Help
Powered by ViewVC 1.1.26