MacOSX-File
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
Catalog/Catalog.pm view on Meta::CPAN
our @ISA = qw(Exporter DynaLoader);
# Items to export into callers namespace by default. Note: do not export
# names by default without a very good reason. Use EXPORT_OK instead.
# Do not simply export all your public functions/methods/constants.
# This allows declaration use MacOSX::File::Catalog ':all';
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
# will save memory.
=head2 EXPORT
Subs: getcatalog(), setcatalog()
=cut
our %EXPORT_TAGS = ( 'all' => [ qw(
) ] );
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
our @EXPORT = qw(
getcatalog
setcatalog
);
bootstrap MacOSX::File::Catalog $VERSION;
use MacOSX::File;
# Preloaded methods go here.
=head1 METHODS
=over 4
=item $catalog = MacOSX::File::Catalog->get($path);
=item $catalog = getfileinfo($path);
Constructs MacOSX::File::Catalog from which you can manipulate file
attributes. On failure, it returns undef and $MacOSX::File::OSErr
is set.
=cut
use MacOSX::File::Constants;
sub getcatalog{
my ($path) = @_;
my $self = xs_getcatalog($path) or return;
@$self or return;
bless $self;
}
sub get{
my ($class, $path) = @_;
my $self = xs_getcatalog($path) or return;
@$self or return;
bless $self => $class;
}
=item $catalog->set([$path]);
=item setcatalog($catalog, [$path]);
Sets file attributes of file $path. If $path is omitted the file you
used to construct $catalog is used. On success, it returns 1. On
failure, it returns 0 and $MacOSX::File::OSErr is set.
Remember any changes to $catalog will not be commited until you call
these functions.
ex)
setcatalog(getcatalog("foo"), "bar");
#Copies file attributes from foo to bar
=cut
sub setcatalog{
my ($catalog, $path) = @_;
ref $catalog eq __PACKAGE__ or return;
return !xs_setcatalog($catalog, $path);
}
sub set{
my ($self, $path) = @_;
ref $self eq __PACKAGE__ or return;
return !xs_setcatalog($self, $path);
}
=item $catalog->dump
returns a pretty-printed string that contains the value of every
(gettable) member of FSCatalogInfo structure.
ex) print $catalog->dump;
=back
=cut
sub dump{
use POSIX qw(strftime);
my $s = shift;
my $t2s = sub {
strftime("%Y.%m.%d %H:%M:%S", localtime($_[0]))
. "." . ($_[0]-int($_[0]));
};
my $octlist = sub { join ",", map {sprintf "0%o" ,$_} @_ };
return
join("\n",
"(FSRef)",
sprintf("nodeFlags => 0x%04x", $s->[1]),
sprintf("volume => %6d", $s->[2]),
sprintf("parentDirID => 0x%08x", $s->[3]),
sprintf("nodeID => 0x%08x", $s->[4]),
sprintf("sharingFlags => 0x%02x", $s->[5]),
sprintf("userPrivileges => 0x%02x", $s->[6]),
sprintf("createDate => %s", $t2s->($s->[7])),
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.544 second using v1.00-cache-2.02-grep-82fe00e-cpan-1925d2aa809 )