Getting the last modified date of a file in C

前端 未结 1 1025
我在风中等你
我在风中等你 2021-01-12 07:05

I want to get the last modified date of a file in C. Almost all sources I found use something along this snippet:

char *get_last_modified(char *file) {
    s         


        
相关标签:
1条回答
  • 2021-01-12 07:31

    On OS X, st_mtimespec.tv_sec is the equivalent of st_mtime.

    To make this portable, do

    #ifdef __APPLE__
    #ifndef st_mtime
    #define st_mtime st_mtimespec.tv_sec
    #endif
    #endif
    

    and then use st_mtime.

    0 讨论(0)
提交回复
热议问题