Allow querying file creation time in nsIFile
Categories
(Core :: XPCOM, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox85 | --- | fixed |
People
(Reporter: mail, Assigned: beth)
References
Details
Attachments
(1 file)
It would be very useful to be able to query file creation time from the nsIFile interface.
This could be made available by a new method like nsresult nsIFile::GetCreationTime(PRTime aCreatedAt&)
.
-
On Windows, this information is provided via the
GetFileTime
syscall. -
On macOS, this information is provided by the
st_birthtimespec
field of the struct returned bystat
(2). -
On Linux (including Android), while most file systems do store the creation time, it is not accessible from any standard syscall. On these platforms we could just return
NS_NOT_AVAILABLE
from the implementation.
Comment 1•5 years ago
|
||
For Linux can't we use statx
? Per https://man7.org/linux/man-pages/man2/statx.2.html the struct contains struct statx_timestamp stx_btime; /* Creation */
. I think the main problem might be that there is no libc API for this.
![]() |
||
Comment 2•5 years ago
|
||
(In reply to Tom Schuster [:evilpie] from comment #1)
For Linux can't we use
statx
? Per https://man7.org/linux/man-pages/man2/statx.2.html the struct containsstruct statx_timestamp stx_btime; /* Creation */
. I think the main problem might be that there is no libc API for this.
Rust to the rescue! https://github.com/rust-lang/rust/blob/ffd59bf9c62125813abae8ca52f0ac3a67459e8f/library/std/src/sys/unix/fs.rs#L91
Assignee | ||
Updated•5 years ago
|
Comment 3•5 years ago
|
||
We don't support statx in our sandbox yet (see https://bugzilla.mozilla.org/show_bug.cgi?id=1673771). It also won't work on older kernels I guess. So be prepared to handle ENOSYS on Linux.
Assignee | ||
Comment 4•5 years ago
|
||
Updated•5 years ago
|
Comment 6•5 years ago
|
||
bugherder |
Description
•