Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > How to copy a file on Windows while preserving permissions

Reply
Thread Tools

How to copy a file on Windows while preserving permissions

 
 
Andrew Koenig
Guest
Posts: n/a
 
      04-12-2007
The answer to this question probably involves pywin32 or a similar library.

I would like to copy a file from one place to another on a Windows machine
while preserving as much of the file permissions as it is possible to
preserve with whatever my program's privileges happen to be. If the file is
a directory (i.e. folder), this might require temporarily granting myself
write permission for the directory so I can (recursively) create files in
it--again, assuming that it is possible to do so.

Obviously it would be necessary to determine whether my program's privileges
are sufficient to solve this problem for the particular files in question.

Can someone who is more familiar than I with the vagaries of Windows file
protection and the Python interfaces available to it point me in a useful
direction?


 
Reply With Quote
 
 
 
 
=?ISO-8859-15?Q?=22Martin_v=2E_L=F6wis=22?=
Guest
Posts: n/a
 
      04-12-2007
> Can someone who is more familiar than I with the vagaries of Windows file
> protection and the Python interfaces available to it point me in a useful
> direction?


To copy a file along with its attributes, try SHFileOperation.

Alternatively, if you have backup privileges, open the file for backup,
then use BackupRead/BackupWrite.

HTH,
Martin
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Preserving file permissions with distutils George Sakkis Python 0 01-14-2009 06:44 PM
Sign preserving Vs value preserving sophia.agnes@gmail.com C Programming 4 12-07-2007 03:14 PM
integral promotion, arithmetic conversion, value preserving, unsigned preserving??? TTroy C Programming 16 01-31-2005 10:20 PM
How to backup a directory while preserving the modified date? JD Computer Support 1 09-16-2004 08:50 AM



Advertisments