=head1 NAME SuikaWiki::DB::FileSystem::LeafProp =head1 SYNOPSIS package Example::WikiDBModule; push our @ISA, 'SuikaWiki::DB::FileSystem::Base'; sub ... { } ... =head1 DESCRIPTION This module is part of SuikaWiki. =cut package SuikaWiki::DB::FileSystem::LeafProp; use strict; our $VERSION=do{my @r=(q$Revision: 1.1 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; require SuikaWiki::DB::FileSystem::Base; push our @ISA, 'SuikaWiki::DB::FileSystem::Base'; use IO::File; use Message::Markup::SuikaWikiConfig20::Parser; my $Parser = new Message::Markup::SuikaWikiConfig20::Parser; sub get ($$$;%) { my ($self, $prop, $key, %opt) = @_; report SuikaWiki::DB::Util::Error -type => 'KEY_INVALID_NAME', key => $key, -object => $self, method => 'get' unless $opt{no_key_check} or $self->__check_key (key => $key); unless ($self->{opened}->{$prop}) { local $Error::Depth = $Error::Depth + 1; $self->open_prop (prop => $prop); } my $path = $self->__key2filepath (key => $key); if ($self->{data}->{$path}) { return $self->{data}->{$path}; } elsif (-e $path) { my $file = new IO::File $path, '<' or report SuikaWiki::DB::Util::Error -type => 'FILE_READ_FAILURE', -object => $self, method => 'get', file => $path, msg => $!; binmode $file; local $/ = undef; return $self->{data}->{$path} = $Parser->parse_text (scalar <$file>); } else { return $self->{data}->{$path} = $Parser->parse_text (''); } } sub set ($$$$;%) { my ($self, $prop, $key, $val, %opt) = @_; report SuikaWiki::DB::Util::Error -type => 'KEY_INVALID_NAME', key => $key, -object => $self, method => 'set' unless $opt{no_key_check} or $self->__check_key (key => $key); report SuikaWiki::DB::Util::Error -type => 'STOP_SET_INVALID_VALUE', key => $key, prop => $prop, -object => $self, method => 'set', value => $val unless ref $val and $val->isa ('Message::Markup::SuikaWikiConfig20::Node'); unless ($self->{opened}->{$prop}) { local $Error::Depth = $Error::Depth + 1; $self->open_prop (prop => $prop); } if ($self->{lock} and not $self->{lock}->writable) { report SuikaWiki::DB::Util::Error -type => 'KEY_SAVE_LOCKED', -object => $self, method => 'set', key => $key, prop => $prop; return 0; } $self->__make_directory (directory => $self->__key2dirpath (fullkey => $key)); my $path = $self->__key2filepath (key => $key); my $file = new IO::File $path, '>' or report SuikaWiki::DB::Util::Error -type => 'FILE_WRITE_FAILURE', -object => $self, method => 'set', file => $path, msg => $!; binmode $file; print $file $val->stringify; $self->{data}->{$path} = $val; close $file; 1; } =head1 LICENSE Copyright 2004 Wakaba . All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; # $Date: 2004/04/25 07:06:50 $