write a file "copy" program in Python for Unix and Windows...

B

Ben Kial

I need to write a program to "copy" files and preserved the files'
atime, mtime, ctime, file permissions. I also need to have this
program working in Unix and Windows, where the "Archive"
attribute on the file also has to be preserved (any more
Windows idiosyncrasies?).

Any help will be very much appreciated. Thanks in advance.


Ben
 
A

Andrew Bennetts

I need to write a program to "copy" files and preserved the files'
atime, mtime, ctime, file permissions. I also need to have this
program working in Unix and Windows, where the "Archive"
attribute on the file also has to be preserved (any more
Windows idiosyncrasies?).

Any help will be very much appreciated. Thanks in advance.

Try shutil.copy2 (and/or other functions in the shutil module).

-Andrew.
 
N

Neil Hodgson

Ben Kial:
I need to write a program to "copy" files and preserved the files'
atime, mtime, ctime, file permissions. I also need to have this
program working in Unix and Windows, where the "Archive"
attribute on the file also has to be preserved (any more
Windows idiosyncrasies?).

The platform copy utilities know more than you want to about file
attributes including Read-only, Hidden, Archive, and System bits, compressed
and encrypted attributes, access control lists, multiple forks and further
esoterica. It probably even has a reasonable idea what to do when the
destination file system is different to the source and so may not, for
example, be able to use Unicode file names or ACLs. On Windows, you could
start with something like

os.system("xcopy /K /X /I c:\\os\\s4\\win32 g:\\xxx")

Another approach is to use the native SHFileOperation API although this
is not wrapped by the Win32 extensions. You could use ctypes to access it.

Neil
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top