os.setLastModificationTime*(file: string, t: times.Time) (#7543)

* add proc toFILETIME to winlean
* add proc toWinTime to times
* add proc setFileTime to winlean
* openHandle with write access
* add proc setLastModificationTime to os
* moved epochDiff,rateDiff constants and proc toWinTime
The constants were moved out of the when defined(JS) block so that they
are alsways available in proc toWinTime.
proc toWinTime was moved above the # Deprecated procs comment. Best new
location seemed to be with the toUnix proc.
This commit is contained in:
Hendrik 2018-04-16 22:03:24 +02:00 • committed by Andreas Rumpf
commit b1b517128e
3 changed files with 35 additions and 6 deletions

View file

@ -1086,3 +1086,14 @@ proc ConvertThreadToFiberEx*(param: pointer, flags: int32): pointer {.stdcall, d
proc DeleteFiber*(fiber: pointer): void {.stdcall, discardable, dynlib: "kernel32", importc.}
proc SwitchToFiber*(fiber: pointer): void {.stdcall, discardable, dynlib: "kernel32", importc.}
proc GetCurrentFiber*(): pointer {.stdcall, importc, header: "Windows.h".}
proc toFILETIME*(t: int64): FILETIME =
## Convert the Windows file time timestamp ``t`` to ``FILETIME``.
result = FILETIME(dwLowDateTime: cast[DWORD](t), dwHighDateTime: DWORD(t shr 32))
type
LPFILETIME* = ptr FILETIME
proc setFileTime*(hFile: HANDLE, lpCreationTime: LPFILETIME,
lpLastAccessTime: LPFILETIME, lpLastWriteTime: LPFILETIME): WINBOOL
{.stdcall, dynlib: "kernel32", importc: "SetFileTime".}