[L] Change in dart/sdk[main]: [dart:io] Support microsecond-precision file timestamps

0 views
Skip to first unread message

Sigurd Meldgaard (Gerrit)

unread,
Jun 2, 2026, 6:28:51 AM (yesterday) Jun 2
to dart-...@luci-project-accounts.iam.gserviceaccount.com, Martin Kustermann, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Martin Kustermann

Sigurd Meldgaard added 3 comments

File runtime/bin/file_macos.cc
Line 535, Patchset 14: if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
Sigurd Meldgaard . unresolved

For consistency with the rest of the file and to ensure future namespace support works as expected, should this use 'StatHelper(namespc, name, &st)' instead of calling 'stat' directly? 'StatHelper' (if it exists or is implemented similarly to other platforms) would typically handle the namespace-to-path resolution.

Note: In the current 'file_macos.cc', 'StatHelper' is indeed used by 'LastModified' and 'LastAccessed'. Using it here would be more consistent.

File runtime/bin/file_win.cc
Line 1039, Patchset 14: AttributesToStatMode(attr_data.dwFileAttributes, path.get());
Sigurd Meldgaard . unresolved

Is it possible for 'path' to be null if 'ToWinAPIPath' fails? Line 1021 checks for this, so 'path.get()' is safe to pass here, but it's good to ensure 'AttributesToStatMode' itself doesn't need to handle a null pointer. Since it's a static helper used only here, the current check is sufficient.

File sdk/lib/io/file_impl.dart
Line 474, Patchset 14: var ms = _lastAccessed(_Namespace._namespace, _rawPath);
Sigurd Meldgaard . unresolved

The variable name 'ms' in the original code likely stood for 'milliseconds'. Now that it returns microseconds, you might want to rename this to 'us' or 'micros' for clarity, similar to how you updated 'millis' to 'micros' in other parts of this file.

Open in Gerrit

Related details

Attention is currently required from:
  • Martin Kustermann
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Icb60d62dc156b014c258985546fc78bdbb926006
Gerrit-Change-Number: 507341
Gerrit-PatchSet: 16
Gerrit-Owner: Sigurd Meldgaard <sig...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Martin Kustermann <kuste...@google.com>
Gerrit-Comment-Date: Tue, 02 Jun 2026 10:28:47 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
unsatisfied_requirement
satisfied_requirement
open
diffy

Sigurd Meldgaard (Gerrit)

unread,
Jun 2, 2026, 6:34:26 AM (yesterday) Jun 2
to dart-...@luci-project-accounts.iam.gserviceaccount.com, Martin Kustermann, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Martin Kustermann

Sigurd Meldgaard added 3 comments

File runtime/bin/file_macos.cc
Line 535, Patchset 14: if (NO_RETRY_EXPECTED(stat(name, &st)) == 0) {
Sigurd Meldgaard . resolved

For consistency with the rest of the file and to ensure future namespace support works as expected, should this use 'StatHelper(namespc, name, &st)' instead of calling 'stat' directly? 'StatHelper' (if it exists or is implemented similarly to other platforms) would typically handle the namespace-to-path resolution.

Note: In the current 'file_macos.cc', 'StatHelper' is indeed used by 'LastModified' and 'LastAccessed'. Using it here would be more consistent.

Sigurd Meldgaard

StatHelper is explicitly designed to fail on directories (it checks S_ISDIR(st->st_mode) and returns false with errno = EISDIR).
File::Stat is the backend for Dart's FileStat.statSync(), which must retrieve metadata for directories and symbolic links as well as regular files. Using StatHelper here would break directory stat operations completely.
On macOS, virtual namespace resolution is not implemented, so StatHelper does not perform namespace mapping.

File runtime/bin/file_win.cc
Line 1039, Patchset 14: AttributesToStatMode(attr_data.dwFileAttributes, path.get());
Sigurd Meldgaard . resolved

Is it possible for 'path' to be null if 'ToWinAPIPath' fails? Line 1021 checks for this, so 'path.get()' is safe to pass here, but it's good to ensure 'AttributesToStatMode' itself doesn't need to handle a null pointer. Since it's a static helper used only here, the current check is sufficient.

Sigurd Meldgaard

Done

File sdk/lib/io/file_impl.dart
Line 474, Patchset 14: var ms = _lastAccessed(_Namespace._namespace, _rawPath);
Sigurd Meldgaard . resolved

The variable name 'ms' in the original code likely stood for 'milliseconds'. Now that it returns microseconds, you might want to rename this to 'us' or 'micros' for clarity, similar to how you updated 'millis' to 'micros' in other parts of this file.

Sigurd Meldgaard

done

Open in Gerrit

Related details

Attention is currently required from:
  • Martin Kustermann
Submit Requirements:
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Icb60d62dc156b014c258985546fc78bdbb926006
Gerrit-Change-Number: 507341
Gerrit-PatchSet: 16
Gerrit-Owner: Sigurd Meldgaard <sig...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Attention: Martin Kustermann <kuste...@google.com>
Gerrit-Comment-Date: Tue, 02 Jun 2026 10:34:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: Sigurd Meldgaard <sig...@google.com>
unsatisfied_requirement
satisfied_requirement
open
diffy

Martin Kustermann (Gerrit)

unread,
Jun 2, 2026, 4:25:12 PM (yesterday) Jun 2
to Sigurd Meldgaard, Slava Egorov, dart-...@luci-project-accounts.iam.gserviceaccount.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Sigurd Meldgaard and Slava Egorov

Martin Kustermann voted and added 5 comments

Votes added by Martin Kustermann

Code-Review+1

5 comments

Commit Message
Line 13, Patchset 16 (Latest):* **`FileStat` decoding**: Changed `FileStat` syncing and async retrieval parsing in `file_system_entity.dart` to decode timestamps in microseconds utilizing `DateTime.fromMicrosecondsSinceEpoch`.
Martin Kustermann . unresolved

Is this message AI generated?

The diff already show these kind of things. It would be nice to keep the CL descriptions to explain high level things and not details that can be seen in the diff.

File runtime/bin/file_win.cc
Line 371, Patchset 16 (Latest):// Returns true if the path refers to a special Windows device name.
Martin Kustermann . unresolved

Maybe @veg...@google.com can validate the windows parts, as he's intimately familiar with "reparse points", etc.

File tests/standalone/io/file_test.dart
Line 1590, Patchset 16 (Latest): File file = new File(newFilePath);
Martin Kustermann . unresolved

nit: omit `new` and use `final`

Line 1601, Patchset 16 (Latest): diff <= 1,
Martin Kustermann . unresolved

Why would the diff not be exactly 0?

Line 1981, Patchset 16 (Latest): testSetLastAccessedMicroseconds();
Martin Kustermann . unresolved

nit: consider keeping the list sorted here

Open in Gerrit

Related details

Attention is currently required from:
  • Sigurd Meldgaard
  • Slava Egorov
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Icb60d62dc156b014c258985546fc78bdbb926006
Gerrit-Change-Number: 507341
Gerrit-PatchSet: 16
Gerrit-Owner: Sigurd Meldgaard <sig...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-Attention: Slava Egorov <veg...@google.com>
Gerrit-Attention: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Tue, 02 Jun 2026 20:25:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
satisfied_requirement
unsatisfied_requirement
open
diffy

Slava Egorov (Gerrit)

unread,
3:54 AM (14 hours ago) 3:54 AM
to Sigurd Meldgaard, Martin Kustermann, dart-...@luci-project-accounts.iam.gserviceaccount.com, rev...@dartlang.org, vm-...@dartlang.org
Attention needed from Sigurd Meldgaard

Slava Egorov added 4 comments

File runtime/bin/file_win.cc
Line 391, Patchset 16 (Latest):static bool IsDevicePath(const wchar_t* path) {
Slava Egorov . unresolved

Why did you decide to implement it this way?

I would be inclined to not bother with supporting some meaningful semantics for paths like `C:\dir\NUL`.

Also handling `\\?\C:\dir\NUL` as equivalent to `NUL` - contrary to WinAPI behavior - seems wrong.

So I'd suggest just delete most of this function.

Line 1093, Patchset 16 (Latest): if (_wcsicmp(ext, L".exe") == 0 || _wcsicmp(ext, L".com") == 0 ||
Slava Egorov . unresolved

You should add a comment here that this is replicating C `stat()` behavior on Windows.

Line 1099, Patchset 16 (Latest): // Replicate the owner's read, write, and execute permissions to the group
Slava Egorov . unresolved

This is a somewhat confusing comment because NTFS permission system is actually more expressive than POSIX one - and it does support group based permissions, but in a more granular way which can't be expressed in terms of POSIX file access mode.

So it's just say that we do what `stat()` does.

Line 1107, Patchset 16 (Latest):void File::Stat(Namespace* namespc, const char* name, int64_t* data) {
Slava Egorov . unresolved

Consider unifying more logic between `File:Stat` and `File::GetType` which also needs to resolve and handle reparse points.

We should have all that logic in one place.

Open in Gerrit

Related details

Attention is currently required from:
  • Sigurd Meldgaard
Submit Requirements:
  • requirement satisfiedCode-Owners
  • requirement satisfiedCode-Review
  • requirement satisfiedCommit-Message-Has-TEST
  • requirement is not satisfiedCore-Library-Review
  • requirement satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: sdk
Gerrit-Branch: main
Gerrit-Change-Id: Icb60d62dc156b014c258985546fc78bdbb926006
Gerrit-Change-Number: 507341
Gerrit-PatchSet: 16
Gerrit-Owner: Sigurd Meldgaard <sig...@google.com>
Gerrit-Reviewer: Martin Kustermann <kuste...@google.com>
Gerrit-Reviewer: Sigurd Meldgaard <sig...@google.com>
Gerrit-Reviewer: Slava Egorov <veg...@google.com>
Gerrit-Attention: Sigurd Meldgaard <sig...@google.com>
Gerrit-Comment-Date: Wed, 03 Jun 2026 07:54:07 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy
Reply all
Reply to author
Forward
0 new messages