aboutsummaryrefslogtreecommitdiffstats
path: root/lib/LXRng/Index/DBI.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/LXRng/Index/DBI.pm')
-rw-r--r--lib/LXRng/Index/DBI.pm21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/LXRng/Index/DBI.pm b/lib/LXRng/Index/DBI.pm
index 55e215d..8fcb391 100644
--- a/lib/LXRng/Index/DBI.pm
+++ b/lib/LXRng/Index/DBI.pm
@@ -535,6 +535,27 @@ sub set_rfile_charset {
return $sth->execute($charset, $rfile_id);
}
+sub get_file_charset {
+ my ($self, $tree, $path, $rel) = @_;
+
+ my $dbh = $self->dbh;
+ my $pre = $self->prefix;
+ my $rel_id = $self->release_id($tree, $rel);
+ return undef unless $rel_id;
+ my $rfile_id = $self->_get_rfile_by_release($rel_id, $path);
+ return undef unless $rfile_id;
+
+ my $sth = $$self{'sth'}{'get_file_charset'} ||=
+ $dbh->prepare(qq{select c.name
+ from ${pre}revisions r, ${pre}charsets c
+ where r.id = ? and r.body_charset = c.id});
+ my $charset;
+ if ($sth->execute($rfile_id) > 0) {
+ ($charset) = $sth->fetchrow_array();
+ }
+ $sth->finish();
+ return $charset;
+}
sub get_rfile_timestamp {
my ($self, $rfile_id) = @_;