nxdk icon indicating copy to clipboard operation
nxdk copied to clipboard

[REQUEST] implementation of FileTimeToLocalFileTime, SystemTimeToFileTime, CompareFileTime, FileTimeToSystemTime and LocalFileTimeToFileTime

Open antonic901 opened this issue 11 months ago • 3 comments

I need those winapi functions for backporting XTimeUtils from Kodi. Source code of that file can be found here.

  • [X] FileTimeToLocalFileTime 51dfb91
  • [X] SystemTimeToFileTime 1a03478
  • [X] CompareFileTime 2c83007
  • [X] FileTimeToSystemTime a4eb21a
  • [ ] LocalFileTimeToFileTime

antonic901 avatar Feb 18 '25 10:02 antonic901

FileTimeToSystemTime and SystemTimeToFileTime are trivially implemented with their kernel counterparts RtlTimeToTimeFields and RtlTimeFieldsToTime. CompareFileTime is also trivially implemented with something like this:

LONG CompareFileTime(const FILETIME *lpFileTime1, const FILETIME *lpFileTime2)
{
    uint64_t ft1, ft2;

    ft1 = ((uint64_t)lpFileTime1->dwHighDateTime << 32 | lpFileTime1->dwLowDateTime);
    ft2 = ((uint64_t)lpFileTime2->dwHighDateTime << 32 | lpFileTime2->dwLowDateTime);

    if (ft1 < ft2) {
        return -1L;
    } else if (ft1 > ft2) {
        return 1L;
    }

    /* we are only here if ft1 == ft2 */
    return 0L;
}

LocalFileTimeToFileTime and FileTimeToLocalFileTime may also be trivial to implement with the already implemented GetTimeZoneInformation and the Bias member of the TIME_ZONE_INFORMATION structure.

mrpapersonic avatar Apr 12 '25 03:04 mrpapersonic

I implemented some of these back in february here, haven't gotten around to finishing and upstreaming yet though

thrimbor avatar Apr 12 '25 13:04 thrimbor

Thanks guys I'm using trimbor implementation and remaining two are ChatGPT implemented. I still wasn't able to test them, hopefully this month I will start on implementing CApplication where those functions are used.

antonic901 avatar Apr 12 '25 20:04 antonic901