Re: file/directory creation date and time
"Tim Bradshaw (as tfb at tfeb dot org)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
Unix does not maintain a file creation timestamp for files. It maintains three timestamps:
• the last time the contents of the file was modified (mtime);
• the last time the status of the file was change (stime);
• the time the file was last accessed (atime);
All of these are unix-epoch based times. See stat(2).
Many filesystems at least used to have options to disable atime updates since they're expensive and unuseful in almost all cases.
The LW functions work fine on directories on macOS anyway:
? (system:get-file-stat (user-homedir-pathname))
#S(system::stat :device 16777229
:inode 3440204
:protection 16877
:links 107
:u-owner 502
:g-owner 502
:device-type 0
:size 3424
:last-access 1764951728
:last-modify 1764951728
:last-change 1764951728
:optimal-block-size 4096
:blocks 0)
> On 5 Dec 2025, at 14:47, John DeSoi (as john at desoi dot dev) <[email protected]> wrote:
>
> "file-create-date" returns no match in the LW documentation search.
>
> I'm not sure what the difference is between system:file-stat-last-change and system:file-stat-last-modify, but they don't give the creation timestamp. And they only work on files, not directories.
>
> The only option I found so far is osicat, but it seems overkill to add it as a dependency only for this purpose. I'll probably have to work out the system API. I only need macOS for now.
>
> Thanks,
>
> John DeSoi, Ph.D.
>
>
>> On Dec 5, 2025, at 1:24 AM, Alexey Veretennikov <[email protected]> wrote:
>>
>> You can use something like this (decode-universal-time (file-create-date "myfile.txt")),
>>
>> or on *nix
>>
>> (system:file-stat-last-change (system:get-file-stat "myfile.txt")) to get Epoch timestamp
>>
>
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html