Skip to content

Inconsistent statSync().mode Behavior: Fails to Differentiate Between Non-Existent and Permission-Denied Files #57111

@stephane-archer

Description

@stephane-archer

Currently, the statSync().mode API in Dart has inconsistent behavior when dealing with non-existent files and files with restricted permissions:

touch MyFile
chmod 000 ./MyFile
var mode = File("MyFile").statSync().mode; // Returns 0 as expected (no permissions). 
var mode = File("notExistingFile").statSync().mode;  
// Also returns 0, which is misleading because the file does not exist.
// Ideally, it should throw an exception to differentiate this case.  

Expected Behavior:
An exception should be thrown for non-existent files to distinguish them from files with restricted permissions.

Actual Behavior:
Both scenarios return 0 from statSync().mode, which can lead to incorrect assumptions in applications.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-iotriagedIssue has been triaged by sub teamtype-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions