The R package fs provides the function file_info() which returns a tibble containing i.a. the variables:
modification_timeThe time of last data modification, as a POSIXct datetime.access_timeThe time of last access - as a POSIXct datetime.change_timeThe time of last file status change - as a POSIXct datetime.
Now I'm wondering what are the differences between modification_time and change_time?
What I noticed so far is that change_time seems to be immune to "chronological inconsistencies". Example:
library(magrittr)
fs::file_create("test_file")
fs::file_info("test_file") %>% dplyr::select(modification_time, access_time, change_time)
#> # A tibble: 1 x 3
#> modification_time access_time change_time
#> <dttm> <dttm> <dttm>
#> 1 2019-10-24 13:23:35 2019-10-24 13:23:35 2019-10-24 13:23:35
# change access and modification times to current Sys.time()
# -> both modification_time and change_time will be updated
Sys.sleep(1)
fs::file_touch("test_file")
fs::file_info("test_file") %>% dplyr::select(modification_time, access_time, change_time)
#> # A tibble: 1 x 3
#> modification_time access_time change_time
#> <dttm> <dttm> <dttm>
#> 1 2019-10-24 13:23:37 2019-10-24 13:23:37 2019-10-24 13:23:37
# change access and modification times to the past (-2 min)
# -> only modification_time will be updated
fs::file_touch("test_file", Sys.time() - 120)
fs::file_info("test_file") %>% dplyr::select(modification_time, access_time, change_time)
#> # A tibble: 1 x 3
#> modification_time access_time change_time
#> <dttm> <dttm> <dttm>
#> 1 2019-10-24 13:21:37 2019-10-24 13:21:37 2019-10-24 13:23:37
# change access and modification times to the future (+5 min)
# -> only modification_time will be updated
fs::file_touch("test_file", Sys.time() + 300)
fs::file_info("test_file") %>% dplyr::select(modification_time, access_time, change_time)
#> # A tibble: 1 x 3
#> modification_time access_time change_time
#> <dttm> <dttm> <dttm>
#> 1 2019-10-24 13:28:37 2019-10-24 13:28:37 2019-10-24 13:23:37
Created on 2019-10-24 by the reprex package (v0.3.0)
The R base function file.mtime() only returns the modification_time from above.