From: Richard D. <ric...@us...> - 2006-08-19 18:27:22
|
Update of /cvsroot/file-extattr/File-ExtAttr/lib/File In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv7869/lib/File Modified Files: ExtAttr.pm Log Message: Add create and replace flags (to replace usage of XATTR_CREATE, XATTR_REPLACE); bugfix: setfattr returns 0 on failure now Index: ExtAttr.pm =================================================================== RCS file: /cvsroot/file-extattr/File-ExtAttr/lib/File/ExtAttr.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** ExtAttr.pm 19 Aug 2006 14:06:25 -0000 1.13 --- ExtAttr.pm 19 Aug 2006 18:27:18 -0000 1.14 *************** *** 218,233 **** C<$filehandle> (which should be an IO::Handle). ! XXX: FIXME: Below ! ! C<$flags> allows control of whether the attribute should be created ! or should replace an existing attribute's value. The value ! C<File::ExtAttr::XATTR_CREATE> will cause setfattr to fail ! if the attribute already exists. The value C<File::ExtAttr::XATTR_REPLACE> ! will cause setfattr to fail if the attribute does not already exist. ! If C<$flags> is omitted, then the attribute will be created if necessary ! or silently replaced. ! ! NOTE: C<XATTR_*> are currently Linux-specific. A more portable set of flags ! is on the to-do list. If the attribute could not be set, a warning is issued. --- 218,227 ---- C<$filehandle> (which should be an IO::Handle). ! C<%flags> allows control of whether the attribute should be created ! or should replace an existing attribute's value. If the key C<create> ! is true, setfattr will fail if the attribute already exists. If the key ! C<replace> is true, setfattr will fail if the attribute ! does not already exist. If neither is specified, then the attribute ! will be created (if necessary) or silently replaced. If the attribute could not be set, a warning is issued. *************** *** 237,247 **** sub setfattr { ! my $file = shift; return _is_fh($file) # File handle ! ? _fsetfattr($file->fileno(), @_) # Filename ! : _setfattr($file, @_); } --- 231,244 ---- sub setfattr { ! my ($file, $attrname, $attrval, $flagsref) = @_; ! ! die "Only one of the 'create' and 'replace' options can be passed to setfattr" ! if ($flagsref->{create} && $flagsref->{replace}); return _is_fh($file) # File handle ! ? _fsetfattr($file->fileno(), $attrname, $attrval, $flagsref) # Filename ! : _setfattr($file, $attrname, $attrval, $flagsref); } |