Re: file/directory creation date and time

Martin Simmons <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <[email protected]>
That's not quite true: some filesystems maintain a birthtime/btime, which is
the time when the file was created.  You can read it by stat(2) on BSD and
macOS systems and by statx(2) on newer versions of Linux but LispWorks doesn't
put in this in the system::stat structure.  E.g. See
https://man.freebsd.org/cgi/man.cgi?query=stat&apropos=0&sektion=2&manpath=FreeBSD+15.0-RELEASE+and+Ports&arch=default&format=html

Also, stime is usually called ctime on Unix.

-- 
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/



>>>>> On Fri, 5 Dec 2025 16:33:51 +0000, Tim Bradshaw (as tfb at tfeb dot org) said:
> 
> 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
> 

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.