Skip to content

<filesystem>: directory_entry does not work for paths on FAT32 filesystems #233

Description

@e4lam

From #232, we had this sample code:

// compile with: cl /std:c++17 /permissive- /EHsc /Od /Zi symlink.cpp
// run: .\symlink does_not_exist
//
#include <filesystem>
#include <iostream>
namespace fs = std::filesystem;

int main(int argc, const char* argv[])
{
  if (argc < 2)
  {
    std::cerr << "Missing file path argument\n";
    return -1;
  }
  fs::path dst(argv[1]);

  std::error_code err1;
  fs::directory_entry src(dst, err1);
  std::cout << "directory_entry(" << dst << ") = " << err1 << " " << err1.message() << "\n";

  std::error_code err2;
  src.refresh(err2);
  std::cout << "refresh(" << dst << ") = " << err2 << " " << err2.message() << "\n";

  return 0;
}

Running this on a FAT32 file system (e.g. on a USB key but I tested with just a RAMDISK formatted to FAT32) gives the following result. (src is a directory on the G: drive demonstrated here)

G:\> /path/to/symlink.exe src
directory_entry("src") = system:0 The operation completed successfully.
refresh("src") = system:87 The parameter is incorrect.

I tried to workaround this by calling std::directory_entry::status( std::error_code& ec ) and std::directory_entry::symlink_status( std::error_code& ec ) as well. But they both fail, giving no way to confirm if a path on a FAT32 filesystem is indeed a directory or not.

I tested this myself on Windows 7, but my colleague who had first encountered the problem narrowed down here I believe was on Windows 10.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfilesystemC++17 filesystemfixedSomething works now, yay!

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions