"Cloning" file attributes and permissions

Paulo da Silva psdasilvaX at esotericaX.ptX
Thu Apr 12 19:09:13 EDT 2007


attn.steven.kuo at gmail.com escreveu:
> On Apr 12, 9:20 am, Paulo da Silva <psdasil... at esotericaX.ptX> wrote:
>> Hi!
>>
>> I need to process a file to produce another file that *must* have
>> *exactly* the same attributes and permissions of the former. What is the
>> best way to do this? The file must not exist with contents (it may exist
>> empty) unless it has the same attributes and permissions.
>> I know how to do this using, let me call it, "C type code" (stat, chmod,
>> chown, etc). I would like to hear some opinions on if and how it would
>> be possible in a more elegant/python way.
>>
> 
> 
> Are you using a system that supports the creation
> of a hard link?
> 
> If so, try os.link.

May be I missed something exposing my q.
I need to process an input file "foo" to produce a different contents
file "bar". "bar" must have the same attributes/permissions of "foo".
I forgot to say that the OS is Linux.



More information about the Python-list mailing list