Of course you can write a more complicated calculation algorithm, but it'll require tons of syscalls to determine the type of the file handle you're interacting with and will be probably very slow.
This is what rustup did inadvertently back in the day, and it caused NTFS to melt down to a halt because of stat() overhead [0].