Skip to content

Commit

Permalink
Merge pull request #5492 from ericmehl/exFAT-fix
Browse files Browse the repository at this point in the history
exFAT workaround
  • Loading branch information
johnhaddon authored Oct 20, 2023
2 parents b8cb5f1 + 18b7a5d commit 3f4f9ac
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Fixes
- PythonEditor :
- Fixed output for `print()` calls with multiple arguments, which was previously spread across multiple lines.
- Fixed bug that prevented editors being destroyed at the right time.
- FileSystemPath : Fixed bug on Windows where paths on an exFAT partition were not considered valid.

1.3.4.0 (relative to 1.3.3.0)
=======
Expand Down
22 changes: 21 additions & 1 deletion src/Gaffer/FileSystemPath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,27 @@ bool FileSystemPath::isValid( const IECore::Canceller *canceller ) const

std::error_code e;

const std::filesystem::file_type t = std::filesystem::symlink_status( std::filesystem::path( this->string() ), e ).type();
std::filesystem::file_type t = std::filesystem::symlink_status( std::filesystem::path( this->string() ), e ).type();

#if defined(_MSC_VER) && _MSC_VER < 1932

// Fix MSVC bug preventing `symlink_status()` working with exFAT partitions, and possibly FAT.
// Filtering to error 87 is based on experimentation and backed up by
// https://github.com/microsoft/STL/issues/233. Using `status()` instead of `symlink_status()`
// allows exFAT partitions to be used, and because exFAT does not support symlinks, this
// should be a valid workaround provided filtering to error value `87` doesn't include
// partitions that do support symlinks.
if(
(
t == std::filesystem::file_type::none || t == std::filesystem::file_type::not_found
) && e.value() == 87 // "The parameter is incorrect."
)
{
t = std::filesystem::status( std::filesystem::path( this->string() ), e ).type();
}

#endif

return t != std::filesystem::file_type::none && t != std::filesystem::file_type::not_found;
}

Expand Down

0 comments on commit 3f4f9ac

Please sign in to comment.