/[fuse_dbi]/trunk/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 /trunk/DBI.pm

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

revision 7 by dpavlin, Sat Aug 7 14:48:23 2004 UTC revision 8 by dpavlin, Sat Aug 7 15:16:50 2004 UTC
# Line 133  sub e_getdir { Line 133  sub e_getdir {
133          if (! %out) {          if (! %out) {
134                  $out{'no files? bug?'}++;                  $out{'no files? bug?'}++;
135          }          }
136          print scalar keys %out," files found for '$dirname': ",keys %out,"\n";          print scalar keys %out," files in dir '$dirname'\n";
137          return (keys %out),0;          return (keys %out),0;
138  }  }
139    
# Line 159  sub e_read { Line 159  sub e_read {
159          # (note: 0 means EOF, "0" will give a byte (ascii "0")          # (note: 0 means EOF, "0" will give a byte (ascii "0")
160          # to the reading program)          # to the reading program)
161          my ($file) = filename_fixup(shift);          my ($file) = filename_fixup(shift);
162          my ($buf,$off) = @_;          my ($buf_len,$off) = @_;
163    
164          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
165    
166          my $len = length($files{$file}{cont});          my $len = length($files{$file}{cont});
167    
168          print "read '$file' [$len bytes] offset $off length $buf\n";          print "read '$file' [$len bytes] offset $off length $buf_len\n";
169    
170          return -EINVAL() if ($off > $len);          return -EINVAL() if ($off > $len);
171          return 0 if ($off == $len);          return 0 if ($off == $len);
172    
173          $buf = $len-$off if ($off+$buf > $len);          $buf_len = $buf_len-$off if ($off+$buf_len > $len);
174    
175          return substr($files{$file}{cont},$off,$buf);          return substr($files{$file}{cont},$off,$buf_len);
176  }  }
177    
178  sub clear_cont {  sub clear_cont {
# Line 190  sub clear_cont { Line 190  sub clear_cont {
190  sub update_db {  sub update_db {
191          my $file = shift || die;          my $file = shift || die;
192    
193            $files{$file}{ctime} = time();
194    
195          if (!$sth_update->execute($files{$file}{cont},$files{$file}{id})) {          if (!$sth_update->execute($files{$file}{cont},$files{$file}{id})) {
196                  print "update problem: ",$sth_update->errstr;                  print "update problem: ",$sth_update->errstr;
197                  clear_cont;                  clear_cont;
# Line 207  sub update_db { Line 209  sub update_db {
209    
210  sub e_write {  sub e_write {
211          my $file = filename_fixup(shift);          my $file = filename_fixup(shift);
212          my ($buf,$off) = @_;          my ($buf_len,$off) = @_;
213    
214          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
215    
216          my $len = length($files{$file}{cont});          my $len = length($files{$file}{cont});
217    
218          print "write '$file' [$len bytes] offset $off length $buf\n";          print "write '$file' [$len bytes] offset $off length\n";
219    
220          $files{$file}{cont} =          $files{$file}{cont} =
221                  substr($files{$file}{cont},0,$off) .                  substr($files{$file}{cont},0,$off) .
222                  $buf .                  $buf_len .
223                  substr($files{$file}{cont},$off+length($buf));                  substr($files{$file}{cont},$off+length($buf_len));
224    
225          if (! update_db($file)) {          if (! update_db($file)) {
226                  return -ENOSYS();                  return -ENOSYS();
227          } else {          } else {
228                  return length($buf);                  return length($buf_len);
229          }          }
230  }  }
231    
# Line 242  sub e_utime { Line 244  sub e_utime {
244    
245          return -ENOENT() unless exists($files{$file});          return -ENOENT() unless exists($files{$file});
246    
247            print "utime '$file' $atime $mtime\n";
248    
249          $files{$file}{time} = $mtime;          $files{$file}{time} = $mtime;
250          return 0;          return 0;
251  }  }

Legend:
Removed from v.7  
changed lines
  Added in v.8

  ViewVC Help
Powered by ViewVC 1.1.26