… | |
… | |
13 | use base 'Exporter'; |
13 | use base 'Exporter'; |
14 | |
14 | |
15 | use Carp (); |
15 | use Carp (); |
16 | use File::Spec; |
16 | use File::Spec; |
17 | use List::Util qw(min max); |
17 | use List::Util qw(min max); |
18 | use Storable; |
18 | use Storable qw(freeze thaw); |
19 | |
19 | |
20 | our @EXPORT = qw( |
20 | our @EXPORT = qw( |
21 | read_pak read_arch *ARCH TILESIZE $TILE *FACE editor_archs arch_extents |
21 | read_pak read_arch *ARCH TILESIZE $TILE *FACE editor_archs arch_extents |
22 | ); |
22 | ); |
23 | |
23 | |
… | |
… | |
56 | open my $fh, "<", $path |
56 | open my $fh, "<", $path |
57 | or die "$path: $!"; |
57 | or die "$path: $!"; |
58 | binmode $fh; |
58 | binmode $fh; |
59 | local $/; |
59 | local $/; |
60 | |
60 | |
61 | Storable::thaw <$fh> |
61 | thaw <$fh> |
62 | } |
62 | } |
63 | |
63 | |
64 | sub save_ref($$) { |
64 | sub save_ref($$) { |
65 | my ($ref, $path) = @_; |
65 | my ($ref, $path) = @_; |
66 | |
66 | |
67 | open my $fh, ">", "$path~" |
67 | open my $fh, ">", "$path~" |
68 | or die "$path~: $!"; |
68 | or die "$path~: $!"; |
69 | binmode $fh; |
69 | binmode $fh; |
70 | print $fh Storable::freeze $ref; |
70 | print $fh freeze $ref; |
71 | close $fh; |
71 | close $fh; |
72 | rename "$path~", $path |
72 | rename "$path~", $path |
73 | or die "$path: $!"; |
73 | or die "$path: $!"; |
74 | } |
74 | } |
75 | |
75 | |