NAME

File::Attributes - Manipulate file metadata

VERSION

Version 0.01

SYNOPSIS

   use File::Attributes qw(set_attribute list_attributes get_all_attributes);

   my $file = 'foo.txt';
   set_attribute($file, type     => 'text/plain');
   set_attribute($file, encoding => 'utf8');
   
   my @attributes = list_attributes($file);
   #  @attributes = qw(type encoding)

   %attributes = get_attributes($file);
   #  $attributes{type} will be 'text/plain'
   #  $attributes{foo}  will be undefined.

DETAILS

File::Attributes is a wrapper around modules in the File::Attributes hierarchy. If you use this module directly (instead of one of the aforementioned decendants), then your attribute manipulations will Just Work, regardless of the underlying filesystem.

As of version 0.01, this works by trying File::Attributes::Extended, and if that fails, File::Attributes::Simple.

Note that if you need specific features of File::Attributes::Extended (like reading attributes that don't start with user.), then you'll need to use File::Attributes::Extended directly. This module prepends 'user.' to everything, for the sake of simplicity and portability. (The 'user.' prefix is only a requirement of Linux, other operating systems let user applications use whatever namespace they like.)

EXPORT

None, by default. Specify the functions that you'd like to use as arguments to the module.

FUNCTIONS

All functions throw an exception on error.

get_attribute($file, $attribute)

Returns the value of attribute $attribute on file $file. If $attribute doesn't exist, returns undefined.

set_attribute($file, $attribute => $value)

Sets attribute $<attribute> on file $file to $value.

get_attributes($file)

Returns a hash of all attributes on $file.

set_attributes($file, %hash)

Sets the attributes named by the keys of %hash to the value contained in %hash. Note that this operation is not atomic -- if setting an individual attribute fails, the attributes on $file may not be the same as before set_attributes was called!

unset_attribute($file, $attribute)

Removes the attribute $attribute from $file.

unset_attributes($file, $attribute0, [$attribute1, ...])

Removes each attribute ($attribute0, $attribute1, ...) from $file.

list_attributes($file)

Returns a list of the attributes on $file. Equivalent to (but faster than) keys get_attributes($file).

AUTHOR

Jonathan Rockway, <jrockway at cpan.org>

BUGS

Please report any bugs or feature requests to RT at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=File-Attributes.

COPYRIGHT & LICENSE

Copyright 2006 Jonathan Rockway, all rights reserved.

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