Skip to content

std.fs.File: stat for windows is not consistent with POSIX and is missing some informations #18290

@perillo

Description

@perillo

The offending source code is: https://github.com/ziglang/zig/blob/779b8e2/lib/std/fs/File.zig#L373.

Note that I'm not an expert of Windows, however I think that the following issue should be fixed:

Using info.BasicInformation.CreationTime as ctime

In POSIX, ctime represent file metadata change. The equivalent of POSIX ctime is info.BasicInformation.ChangetimeTime, not CreationTime.

See https://devblogs.microsoft.com/oldnewthing/20100709-00/?p=13463 for an unofficial reference.

Supporting only kind of type .file or `.directory

Windows supports symbolic links in info.BasicInformation.FileAttributes and in info.StandardInformation.NumberOfLinks.
Zig should support them, if the semantic is compatible with POSIX.

Add birthtime to std.fs.File.Stat

Since Windows and some POSIX systems like Linux (ext4 and btrfs), BSD (ufs2) and Solaris (zfs) supports birthtime, Zig should add an optional birthtime field to Stat.

Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorenhancementSolving this issue will likely involve adding new logic or components to the codebase.os-windowsMicrosoft Windowsstandard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions