C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Revising #pragma once

From: Jonathan Wakely <cxx_at_[hidden]>
Date: Fri, 30 Aug 2024 07:56:50 +0100
On Fri, 30 Aug 2024, 02:42 Thiago Macieira via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> On Thursday 29 August 2024 16:10:35 GMT-7 Jeremy Rifkin via Std-Proposals
> wrote:
> > if by std::filesystem::equivalent, otherwise implementation defined. But
> > "filesystem" would need to be defined.
>
> libstdc++:
> fs::equiv_files([[maybe_unused]] const char_type* p1, const stat_type& st1,
> [[maybe_unused]] const char_type* p2, const stat_type& st2,
> [[maybe_unused]] error_code& ec)
> {
> // For POSIX the device ID and inode number uniquely identify a file.
> // This doesn't work on Windows (see equiv_files in src/c++17/fs_ops.cc).
> return st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino;
> }
>
> libc++'s implementation is the same:
> inline bool stat_equivalent(const StatT& st1, const StatT& st2) {
> return (st1.st_dev == st2.st_dev && st1.st_ino == st2.st_ino);
> }
>
> At least Microsoft's works on Windows. Like Qt, it uses
> GetFileInformationByHandleEx.


So does libstdc++, the code you showed above is for
std::experimental::filesystem::equivalent which doesn't work on Windows.
For std::filesystem::equivalent there's a different implementation for
Windows. That's what the comment refers to.


Though Qt's source code has a comment that that
> was known to fail on FAT32...
>
> And as Jonathan replied, "uniquely identifies" is an oversimplification,
> even
> for POSIX systems. If we standardise on the standard library's behaviour,
> then
> MSVC's behaviour on Windows will differ from Clang's and GCC's.
>
>
> Side note:
> Qt uses this to determine whether, when renaming a file, you're trying to
> overwrite something or change the case of the file's name. So we have a
> workaround for that for systems that don't usually expect case-insensitive
> filesystems.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> Principal Engineer - Intel DCAI Platform & System Engineering
>
>
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2024-08-30 06:58:10