authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2023-12-19 21:07:22-08:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2023-12-20 19:43:28+02:00
logdd189a354bf1c77b1996725902c7f29526cc22a4
tree488e71c851ad34bcdf3f8514881687b951367f51
parent697b8f7d2f043a40e3ec830625d3a54c9da68923

Fix `Stat.ctime` docs, and correct its value on Windows

ctime is last file status/metadata change, not creation time. Note that this mistake was not made in the `File.metadata`/`File.Metadata` implementation, which allows getting the actual creation time. Closes #18290

1 files changed, 5 insertions(+), 3 deletions(-)

lib/std/fs/File.zig+5-3
...@@ -315,11 +315,11 @@ pub const Stat = struct {...@@ -315,11 +315,11 @@ pub const Stat = struct {
315 mode: Mode,315 mode: Mode,
316 kind: Kind,316 kind: Kind,
317317
318 /// Access time in nanoseconds, relative to UTC 1970-01-01.318 /// Last access time in nanoseconds, relative to UTC 1970-01-01.
319 atime: i128,319 atime: i128,
320 /// Last modification time in nanoseconds, relative to UTC 1970-01-01.320 /// Last modification time in nanoseconds, relative to UTC 1970-01-01.
321 mtime: i128,321 mtime: i128,
322 /// Creation time in nanoseconds, relative to UTC 1970-01-01.322 /// Last status/metadata change time in nanoseconds, relative to UTC 1970-01-01.
323 ctime: i128,323 ctime: i128,
324324
325 pub fn fromSystem(st: posix.system.Stat) Stat {325 pub fn fromSystem(st: posix.system.Stat) Stat {
...@@ -369,6 +369,8 @@ pub const Stat = struct {...@@ -369,6 +369,8 @@ pub const Stat = struct {
369369
370pub const StatError = posix.FStatError;370pub const StatError = posix.FStatError;
371371
372/// Returns `Stat` containing basic information about the `File`.
373/// Use `metadata` to retrieve more detailed information (e.g. creation time, permissions).
372/// TODO: integrate with async I/O374/// TODO: integrate with async I/O
373pub fn stat(self: File) StatError!Stat {375pub fn stat(self: File) StatError!Stat {
374 if (builtin.os.tag == .windows) {376 if (builtin.os.tag == .windows) {
...@@ -392,7 +394,7 @@ pub fn stat(self: File) StatError!Stat {...@@ -392,7 +394,7 @@ pub fn stat(self: File) StatError!Stat {
392 .kind = if (info.StandardInformation.Directory == 0) .file else .directory,394 .kind = if (info.StandardInformation.Directory == 0) .file else .directory,
393 .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),395 .atime = windows.fromSysTime(info.BasicInformation.LastAccessTime),
394 .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime),396 .mtime = windows.fromSysTime(info.BasicInformation.LastWriteTime),
395 .ctime = windows.fromSysTime(info.BasicInformation.CreationTime),397 .ctime = windows.fromSysTime(info.BasicInformation.ChangeTime),
396 };398 };
397 }399 }
398400