/[suikacvs]/webroot/swe/lib/SWE/DB/IDText.pm
Suika

Contents of /webroot/swe/lib/SWE/DB/IDText.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Sun Nov 9 14:08:58 2008 UTC (16 years, 5 months ago) by wakaba
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +2 -3 lines
++ swe/lib/SWE/DB/ChangeLog	9 Nov 2008 14:08:47 -0000
	* VersionControl.pm: New module.

	* HashedProps.pm, IDText.pm: Support for |version_control|
	property is added.

	* SuikaWiki3PageList.pm (_save_data): Renamed as |save_data|.  Do
	nothing if the data has not been loaded from the file.
	(delete_data): New method.

2008-11-09  Wakaba  <wakaba@suika.fam.cx>

1 package SWE::DB::IDText;
2 use strict;
3
4 require SWE::DB::IDProps;
5 push our @ISA, 'SWE::DB::IDProps';
6
7 sub new ($) {
8 my $self = shift->SUPER::new (@_);
9 $self->{leaf_suffix} = '.txt';
10 return $self;
11 } # new
12
13 sub get_data ($$) {
14 my $self = shift;
15 my $file_name = $self->_get_file_name ($_[0]);
16
17 unless (-f $file_name) {
18 return undef;
19 }
20
21 open my $file, '<:encoding(utf8)', $file_name or die "$0: $file_name: $!";
22 local $/ = undef;
23 return \ (<$file>);
24 } # get_data
25
26 sub set_data ($$$) {
27 my $self = shift;
28 my $file_name = $self->_get_file_name ($_[0], 1);
29 my $textref = $_[1];
30
31 open my $file, '>:encoding(utf8)', $file_name or die "$0: $file_name: $!";
32 print $file $$textref;
33 close $file;
34
35 $self->{version_control}->add_file ($file_name) if $self->{version_control};
36 } # set_data
37
38 1;

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24