in reply to Copy preserving attributes

If you want Perl to handle the attributes:

stat
chown
chmod

Replies are listed 'Best First'.
Re^2: Copy preserving attributes
by puterboy (Scribe) on Nov 02, 2009 at 19:04 UTC
    any solution for extended attributes/ACLs? Or is that too system specific.

    Also, how does the efficiency of a single cp system call compare to the code you would have to read and then set timestamp/ownership/permissions internally in perl?

      Considering that the running time of the 'cp' is most likely to be bound by disk I/O, I wouldn't worry about the overhead of calling 'cp'.

      Specially if you have the need to take care of system specifics (like extended attributes/ACLs), I would prefer calling the systems 'cp' then doing it all yourself. Specially if you don't have access to all the environments the program is supposed to run in.

        I'd have to agree with JavaFan, especially considering those new-fangled attributes. One potential for optimization, if you're not renaming files: you could gather them up by destination directory, and copy multiple files within one command. Not the best solution for error reporting though.