En Sat, 04 Jul 2009 03:31:11 -0300, Robert <kxrobe...@googlemail.com> escribió:
Guess this is wrong in win32file; or win32file looses info by early conversion to digits.
There is certainly something fishy with win32file. GetFileTime/SetFileTime don't even agree about the times being local or UTC: from win32file import CreateFile, SetFileTime, GetFileTime, CloseHandle from win32file import GENERIC_READ, GENERIC_WRITE, OPEN_EXISTING fn = "test.txt" fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, 0) sts, creationTime, accessTime, writeTime = GetFileTime(fh) print creationTime, accessTime, writeTime SetFileTime(fh, creationTime, accessTime, writeTime) CloseHandle(fh) fh = CreateFile(fn, GENERIC_READ | GENERIC_WRITE, 0, None, OPEN_EXISTING, 0, 0) sts, creationTime, accessTime, writeTime = GetFileTime(fh) print creationTime, accessTime, writeTime CloseHandle(fh) Each time the script is executed, the file's times advances by 3 hours (I am located at GMT-3). D:\temp>python testfiletime.py 07/06/09 04:13:12 07/06/09 04:50:36 06/10/07 09:38:26 07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26 D:\temp>python testfiletime.py 07/06/09 07:13:12 07/06/09 07:50:36 06/10/07 12:38:26 07/06/09 10:13:12 07/06/09 10:50:36 06/10/07 15:38:26 D:\temp>dir test.txt El volumen de la unidad D es Dardo El número de serie del volumen es: 9884-7F48 Directorio de D:\temp 10/06/2007 12:38 21.468 test.txt 1 archivos 21.468 bytes 0 dirs 204.499.968 bytes libres To restore the same date/time, I have to use: from pywintypes import Time creationTime, accessTime, writeTime = [Time(timegm(localtime(int(t)))) for t in GetFileTime(fh)[1:]] -- Gabriel Genellina _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32