Parent Directory
|
Revision Log
Experimental paragraph-oriented wiki implementation
| 1 | wakaba | 1.1.2.1 | |
| 2 | =head1 NAME | ||
| 3 | |||
| 4 | SuikaWiki::DB::FileSystem::Base | ||
| 5 | |||
| 6 | =head1 SYNOPSIS | ||
| 7 | |||
| 8 | package Example::WikiDBModule; | ||
| 9 | push our @ISA, 'SuikaWiki::DB::FileSystem::Base'; | ||
| 10 | |||
| 11 | sub ... { | ||
| 12 | |||
| 13 | } | ||
| 14 | |||
| 15 | ... | ||
| 16 | |||
| 17 | =head1 DESCRIPTION | ||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | This module is part of SuikaWiki. | ||
| 22 | |||
| 23 | =cut | ||
| 24 | |||
| 25 | package SuikaWiki::DB::FileSystem::Seq; | ||
| 26 | use strict; | ||
| 27 | our $VERSION=do{my @r=(q$Revision: 1.3 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; | ||
| 28 | require SuikaWiki::DB::Util; | ||
| 29 | push our @ISA, 'SuikaWiki::DB::Util::template'; | ||
| 30 | require File::Spec; | ||
| 31 | require IO::Dir; | ||
| 32 | use File::Path; | ||
| 33 | |||
| 34 | sub get ($$$;%) { | ||
| 35 | my ($self, $prop, $key, %opt) = @_; | ||
| 36 | report SuikaWiki::DB::Util::Error | ||
| 37 | -type => 'KEY_INVALID_NAME', key => $key, | ||
| 38 | -object => $self, method => 'get' | ||
| 39 | unless $opt{no_key_check} or | ||
| 40 | $self->__check_key (key => $key); | ||
| 41 | |||
| 42 | unless ($self->{opened}->{$prop}) { | ||
| 43 | local $Error::Depth = $Error::Depth + 1; | ||
| 44 | $self->open_prop (prop => $prop); | ||
| 45 | } | ||
| 46 | |||
| 47 | my $path = $self->__key2filepath (key => $key); | ||
| 48 | |||
| 49 | if (-e $path) { | ||
| 50 | my $file = new IO::File $path, '<' | ||
| 51 | or report SuikaWiki::DB::Util::Error | ||
| 52 | -type => 'FILE_READ_FAILURE', | ||
| 53 | -object => $self, method => 'get', | ||
| 54 | file => $path, msg => $!; | ||
| 55 | binmode $file; | ||
| 56 | local $/ = undef; | ||
| 57 | return scalar <$file>; | ||
| 58 |