On 12 April 2010 15:41:18 UTC+1, Phil Harvey via RT
<bug-Image-ExifTool@rt.cpan.org> wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=56487 >
>
> On Mon Apr 12 10:05:39 2010, rrt wrote:
>> the file is modified, so
>> why would one want to preserve the mtime?
>
> I know I use mtime myself for sorting images, and they sort wrong if this is changed.
Fair enough.
Show quoted text>> Are there any good reasons NOT to preserve file metadata?
>
> I would call this filesystem metadata,
Sorry, my sloppiness.
Show quoted text> The only reason not to preserve this is that I don't know how to do this in a system
> independent way without a big performance impact. Remember, this must work on Windows
> and Mac systems too.
OK, but supporting some of them, as you say below:
Show quoted text> I looked into how I could preserve the permissions, and this is quite easy using the standard
> Perl functions fstat and chmod. But then there are other things like the user/group
> ownership that I haven't looked into yet,
This is easy with standard perl stat/chown.
Show quoted text> and I don't know anything about these extended
> attributes that you mentioned.
File::ExtAttr handles these. One could easily support them only on
systems that have them.
Show quoted text> Also on Mac systems there are things like file creation date
> (ouch! -- no standard Perl functions to handle this one!), file comments, icon position, etc,
> etc.
So, this needs extra, system-dependent support. But it's no disaster
if at least at first things like this aren't supported.
I came up with a simple extensible API for handling this:
# Get attributes of a file
# N.B. Treat return values as a list, don't rely on the actual values here
# i.e. call attrs_set($file1, attrs_get($file2)), that way the
# attributes saved can be extended without breaking the API.
# FIXME: Support extended attributes.
sub attrs_get {
my ($file) = @_;
my ($mode, $uid, $gid) = (stat($file))[2, 4, 5];
$mode = $mode & 07777;
return $mode, $uid, $gid;
}
# Set attributes of a file previously saved with attrs_save
# file: file to set attributes of
# ...: attributes list returned by attrs_get
sub attrs_set {
my ($file, $mode, $uid, $gid) = @_;
chmod $mode, $file;
chown $uid, $gid, $file;
}
Show quoted text> I don't know what security problems they are talking about.
Is there something unclear on that page? For starters:
Show quoted text> 1) Create new file with name "INFILE_exiftool_tmp".
Oops. This is attackable. Use File::Temp or similar for secure
temporary file creation.
--
http://rrt.sc3d.org