Clarification about stat.birthtime
fabiospampinato opened this issue · comments
I've noticed the readme says:
On the other hand the birthtime and birthtimeMs values are undefined on Unix.
Assuming that you were talking about unix-y systems and not exactly Unix I can't reproduce this on both macOS and Lubuntu:
So I'm not sure what to take of that. Has this been "fixed" in more recent versions of node? Does it only happen on some specific filesystems? Are you actually talking about the Unix here?
Thanks!
Thanks for finding this out, this is completely wrong indeed, I am going to fix it.
I do think that birthtime
is not completely cross-platform. Specifically Linux does not have any concept of birthtime
so I think Node.js is re-using the ctime
but that's not really a proper creation timestamp. On Mac and Windows it seems to work just fine though.
Please correct me if I'm wrong. I am going to make further research to either remove that line or edit it.
You're also probably right that is filesystem-specific. In the guide I have conflated filesystems and OS for simplicity sake though. For example issues I flag NTFS-specific issues as Windows issues, even though NTFS partitions are possible on Linux.
Do you have some ideas?
@allcontributors[bot] please add @fabiospampinato for contributing with fixing the documentation.
I've put up a pull request to add @fabiospampinato! 🎉
@ehmicky I don't really know anything more about this, sorry. It might be a good idea to check what Node is actually doing here by reading its source code.
Btw this is a pretty cool project, thanks for making it!
After some research I found out that Node.js uses the stat
field stx_btime
. This field seems to have been recently added to the Linux kernel, but might have been present before that on BSD and Mac.
However when I try to touch
a file on Linux, it updates its birthtime
. It seems to always match the ctime
. But on Windows and Mac it works.
Tanti grazii! If you like the project, please share it on social media so that other developers can write more cross-platform Node.js, which is something often neglected. :) Also finding errors or missing information is a great way to improve this guide!