Menu

#5 Let sd_stat_ctime work on Windows

accepted
windows (1)
5
2015-05-19
2015-04-17
Mark Smit
No

In file sd_xplatform.c the function sd_stat_ctime returns -1 on native Windows platforms. As experiment I took the code based on the POSIX implementation and modified it to use st_mtime instead of st_ctime. In my opinion this works nice, at least it works fine in my code.
Isn't it wise to add this? If not, why?
Complete code:

int sd_stat_ctime(const char* path, time_t* time)
{
    struct stat astat;
    int statret=stat(path,&astat);
    if (0 != statret)
    {
        return statret;
    }
    *time=astat.st_mtime;
    return statret;
}

Discussion

  • František Dvořák

    Is the problem here when using compiler different from MinGW? (MSVC build wasn't updated after 2006)

    st_ctime may be slightly better as it will notice also owner/permissions changes, but maybe it is not needed for reread feature and can be changed to st_mtime for all platforms.

     
  • Mark Smit

    Mark Smit - 2015-05-18

    I'm using a MSVC compiler and it is not possible to use MinGW instead.
    I agree, st_ctime is better in POSIX. But in Windows this field means 'create time' and thus is of no use in this situation.

     
  • František Dvořák

    The MinGW port is nice, because it is only yet another platform added to the existing build system based on autotools. But if the MSVC port has it's users and developers and still works, it is perfectly OK. :-)

    Did you try the MinGW-compiled binary with the MSVC? (I'm just interested, if there isn't any problem with such combination.)

    Which version of MSVC do you use? (if MSVC 6 will be still fine)

     
  • František Dvořák

    • status: open --> accepted
    • assigned_to: František Dvořák
     
  • Mark Smit

    Mark Smit - 2015-05-19

    I have not tried the MinGW compiled binary, so no information there.

    Currently I use VS2010 and VS2013 and they both compile 32 and 64 bit. I created new solutions based on the VC6 one, so that solution is for my project good enough.

     

Log in to post a comment.