ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra-Client/DC.pm
(Generate patch)

Comparing deliantra/Deliantra-Client/DC.pm (file contents):
Revision 1.201 by root, Sun Jan 11 03:19:47 2009 UTC vs.
Revision 1.210 by root, Fri Jan 15 15:19:47 2010 UTC

17use Carp (); 17use Carp ();
18 18
19our $VERSION; 19our $VERSION;
20 20
21BEGIN { 21BEGIN {
22 $VERSION = '2.02'; 22 $VERSION = '2.10';
23 23
24 use XSLoader; 24 use XSLoader;
25 XSLoader::load "Deliantra::Client", $VERSION; 25 XSLoader::load "Deliantra::Client", $VERSION;
26} 26}
27 27
34use Pod::POM (); 34use Pod::POM ();
35use File::Path (); 35use File::Path ();
36use Storable (); # finally 36use Storable (); # finally
37use Fcntl (); 37use Fcntl ();
38use JSON::XS qw(encode_json decode_json); 38use JSON::XS qw(encode_json decode_json);
39 39use Guard qw(guard);
40=item guard { BLOCK }
41
42Returns an object that executes the given block as soon as it is destroyed.
43
44=cut
45
46sub guard(&) {
47 bless \(my $cb = $_[0]), "DC::Guard"
48}
49
50sub DC::Guard::DESTROY {
51 ${$_[0]}->()
52}
53 40
54=item shorten $string[, $maxlength] 41=item shorten $string[, $maxlength]
55 42
56=cut 43=cut
57 44
154sub find_rcfile($) { 141sub find_rcfile($) {
155 my $path; 142 my $path;
156 143
157 for (@RC_PATH, "") { 144 for (@RC_PATH, "") {
158 $path = "$RC_BASE/$_/$_[0]"; 145 $path = "$RC_BASE/$_/$_[0]";
159 return $path if -r $path; 146 return $path if -e $path;
160 } 147 }
161 148
162 die "FATAL: can't find required file \"$_[0]\" in \"$RC_BASE\"\n"; 149 die "FATAL: can't find required file \"$_[0]\" in \"$RC_BASE\"\n";
163} 150}
164 151
167 154
168 open my $fh, $file 155 open my $fh, $file
169 or return; 156 or return;
170 157
171 local $/; 158 local $/;
172 JSON::XS->new->utf8->relaxed->decode (<$fh>) 159 eval { JSON::XS->new->utf8->relaxed->decode (<$fh>) }
173} 160}
174 161
175sub set_theme($) { 162sub set_theme($) {
176 return if $RC_THEME eq $_[0]; 163 return if $RC_THEME eq $_[0];
177 $RC_THEME = $_[0]; 164 $RC_THEME = $_[0];

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines