Image-ExifTool

 view release on metacpan or  search on metacpan

lib/Image/ExifTool/PLIST.pm  view on Meta::CPAN

        RAF => $raf,
        RefSize => $refSize,
        RefProc => $refProc,
        Table => \@table,
        TagTablePtr => $tagTablePtr,
    );
    # position file pointer at the top object, and extract it
    $raf->Seek($table[$topObj], 0) or return 0;
    $$dirInfo{Value} = ExtractObject($et, \%plistInfo);
    return defined $$dirInfo{Value} ? 1 : 0;
}

#------------------------------------------------------------------------------
# Extract information from a PLIST file (binary, XML or JSON format)
# Inputs: 0) ExifTool object ref, 1) dirInfo ref, 2) tag table ref
# Returns: 1 on success, 0 if this wasn't valid PLIST
sub ProcessPLIST($$;$)
{
    my ($et, $dirInfo, $tagTablePtr) = @_;
    my $dataPt = $$dirInfo{DataPt};
    my $start = $$dirInfo{DirStart} || 0;
    my ($result, $notXML);

    if ($dataPt) {
        pos($$dataPt) = $start;
        $notXML = 1 unless $$dataPt =~ /\G</g;
    }
    unless ($notXML) {
        # process XML PLIST data using the XMP module
        $$dirInfo{XMPParseOpts}{FoundProc} = \&FoundTag;
        $result = Image::ExifTool::XMP::ProcessXMP($et, $dirInfo, $tagTablePtr);
        delete $$dirInfo{XMPParseOpts};
        return $result if $result;
    }
    my $buff;
    my $raf = $$dirInfo{RAF};
    if ($raf) {
        $raf->Seek(0,0) and $raf->Read($buff, 64) or return 0;
        $dataPt = \$buff;
    } else {
        return 0 unless $dataPt;
    }
    pos($$dataPt) = $start;
    if ($$dataPt =~ /\Gbplist0/) {  # binary PLIST
        # binary PLIST file
        my $tagTablePtr = GetTagTable('Image::ExifTool::PLIST::Main');
        $et->SetFileType('PLIST', 'application/x-plist');
        $$et{SET_GROUP1} = 'PLIST';
        unless (ProcessBinaryPLIST($et, $dirInfo, $tagTablePtr)) {
            $et->Error('Error reading binary PLIST file');
        }
        delete $$et{SET_GROUP1};
        $result = 1;
    } elsif ($$dataPt =~ /^\{"/) { # JSON PLIST
        $raf and $raf->Seek(0);
        require Image::ExifTool::JSON;
        $result = Image::ExifTool::JSON::ProcessJSON($et, $dirInfo);
    } elsif ($$et{FILE_EXT} and $$et{FILE_EXT} eq 'PLIST' and
        $$dataPt =~ /^\xfe\xff\x00/)
    {
        # (have seen very old PLIST files encoded as UCS-2BE with leading BOM)
        $et->Error('Old PLIST format currently not supported');
        $result = 1;
    }
    return $result;
}

1;  # end

__END__

=head1 NAME

Image::ExifTool::PLIST - Read Apple PLIST information

=head1 SYNOPSIS

This module is used by Image::ExifTool

=head1 DESCRIPTION

This module contains the routines used by Image::ExifTool to extract
information from Apple Property List files.

=head1 NOTES

This module decodes both the binary and XML-based PLIST format.

=head1 AUTHOR

Copyright 2003-2026, Phil Harvey (philharvey66 at gmail.com)

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=head1 REFERENCES

=over 4

=item L<http://www.apple.com/DTDs/PropertyList-1.0.dtd>

=item L<http://opensource.apple.com/source/CF/CF-550/CFBinaryPList.c>

=back

=head1 SEE ALSO

L<Image::ExifTool::TagNames/PLIST Tags>,
L<Image::ExifTool(3pm)|Image::ExifTool>

=cut



( run in 0.501 second using v1.01-cache-2.11-cpan-39bf76dae61 )