Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   write a file "copy" program in Python for Unix and Windows... (http://www.velocityreviews.com/forums/t322993-write-a-file-copy-program-in-python-for-unix-and-windows.html)

Ben Kial 09-29-2003 01:59 AM

write a file "copy" program in Python for Unix and Windows...
 
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



Andrew Bennetts 09-29-2003 02:09 AM

Re: write a file "copy" program in Python for Unix and Windows...
 
On Mon, Sep 29, 2003 at 01:59:52AM +0000, Ben Kial wrote:
> 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.



Miki Tebeka 09-29-2003 06:26 AM

Re: write a file "copy" program in Python for Unix and Windows...
 
Hello Ben,

> 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?).

http://www.python.org/doc/current/li...le-shutil.html

HTH.
Miki

Neil Hodgson 09-29-2003 08:33 AM

Re: write a file "copy" program in Python for Unix and Windows...
 
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




All times are GMT. The time now is 07:41 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.