1 |
wakaba |
1.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 |
wakaba |
1.2 |
close $file; |
34 |
wakaba |
1.1 |
|
35 |
wakaba |
1.2 |
$self->{version_control}->add_file ($file_name) if $self->{version_control}; |
36 |
wakaba |
1.1 |
} # set_data |
37 |
|
|
|
38 |
|
|
1; |