Googler
Сообщения: 3665
Благодарности: 1563
|
Профиль
|
Отправить PM
| Цитировать
Creat0R
Цитата Creat0R:
Установленные секунды округляются до чётного числа »
|
нет, баг не в этом - для FAT четное число будет всегда, просто AutoIT округляет неправильно... вот цитата из MSDN:
Цитата:
Not all file systems can record creation and last access time and not all file systems record them in the same manner. For example, on NT FAT, create time has a resolution of 10 milliseconds, write time has a resolution of 2 seconds, and access time has a resolution of 1 day (really, the access date). On NTFS, access time has a resolution of 1 hour. Therefore, the GetFileTime function may not return the same file time information set using the SetFileTime function. Furthermore, FAT records times on disk in local time. However, NTFS records times on disk in UTC.
|
вот вариант UDF, который показывает заодно и причину округления:
Код: 
$File = "s:\Test.txt"
$hOpenFile = FileOpen($File, 2)
FileWrite($hOpenFile, "Test")
FileClose($hOpenFile)
$SetTime = '20060322083528' ; - 2
_FileSetTime($File, $SetTime)
;FileSetTime($File, $SetTime)
$GetTime = FileGetTime($File, 0, 1)
MsgBox(0, "", StringFormat("Set Time: %s \nGet Time: %s", $SetTime, $GetTime))
FileDelete($File)
Func _FileSetTime($strFile, $strTime, $intType = 0)
Local $iY=Number(StringLeft($strTime,4))
Local $iM=Number(StringMid($strTime,5,2))
Local $iD=Number(StringMid($strTime,7,2))
Local $iH=Number(StringMid($strTime,9,2))
Local $iN=Number(StringMid($strTime,11,2))
Local $iS=Number(StringMid($strTime,13))
; DOS-формат для времени
Local $iFatDate = BitShift($iY-1980,-9) + BitShift($iM,-5) + $iD
Local $iFatTime = BitShift($iH,-11) + BitShift($iN,-5) + $iS/2 ; вот тут косячок в хранении секунд
; базовые структуры
Local $FILETIME = DllStructCreate("dword;dword")
Local $SYSTEMTIME = DllStructCreate("ushort;ushort;ushort;ushort;ushort;ushort;ushort;ushort")
; туда-сюда-обратно
Local $ret = DllCall("kernel32.dll", "int", "DosDateTimeToFileTime", "ushort", $iFatDate, "ushort", $iFatTime, "ptr", DllStructGetPtr($FILETIME))
If $ret[0] =0 Then Return SetError(1, 1, False)
$ret = DllCall("kernel32.dll", "int", "FileTimeToSystemTime", "ptr", DllStructGetPtr($FILETIME), "ptr", DllStructGetPtr($SYSTEMTIME))
If $ret[0] =0 Then Return SetError(1, 2, False)
DllStructSetData($SYSTEMTIME,7,$iS) ; пытаемся откорректировать
$ret = DllCall("kernel32.dll", "int", "SystemTimeToFileTime", "ptr", DllStructGetPtr($SYSTEMTIME), "ptr", DllStructGetPtr($FILETIME))
If $ret[0] =0 Then Return SetError(1, 3, False)
; открываем файл
$ret = DllCall("kernel32.dll", "int", "CreateFile", _
"str", $strFile, "dword", 0x100, "dword", 0, "ptr", 0, "dword", 3, "dword", 0, "ptr", 0 )
If $ret[0] =0 Then Return SetError(2, 1, False)
; правим время и закрываем файл
Local $hFile=$ret[0], $aSysTime[3] = [0,0,0]
$aSysTime[$intType]=DllStructGetPtr($FILETIME)
$ret = DllCall("kernel32.dll", "int", "SetFileTime", "int", $hFile, "ptr", $aSysTime[1], "ptr", $aSysTime[2], "ptr", $aSysTime[0])
DllCall("kernel32.dll", "int", "CloseHandle", "int", $hFile)
If $ret[0] =0 Then Return SetError(2, 2, False)
Return True
EndFunc
Цитата Creat0R:
А на счёт печяти никто так и не знает решения? amel27, не подскажешь? »
|
может невнимательно читал, но ты про что? 
|