Skip to content

Commit

Permalink
. and .. are valid paths (#70770)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qrox authored and Procyonae committed May 14, 2024
1 parent d5b0edc commit cc9908d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -578,12 +578,14 @@ std::string ensure_valid_file_name( const std::string &file_name )
bool is_lexically_valid( const fs::path &path )
{
// Windows has strict rules for file naming
fs::path valid = path.root_path();
fs::path rel = path.relative_path();
// "Do not end a file or directory name with a space or a period."
// https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions
for( auto &it : rel ) {
std::string item = it.generic_u8string();
if( item == "." || item == ".." ) {
continue;
}
if( !item.empty() && ( item.back() == ' ' || item.back() == '.' ) ) {
return false;
}
Expand Down

0 comments on commit cc9908d

Please sign in to comment.