Skip to content

Commit

Permalink
Merge pull request #93564 from Calinou/project-user-dir-prevent-trail…
Browse files Browse the repository at this point in the history
…ing-periods

Prevent folder names with trailing periods from being used automatically
  • Loading branch information
akien-mga committed Jun 26, 2024
2 parents 0364443 + 492787b commit 6cdd303
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion core/os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_paths) const
for (int i = 0; i < invalid_chars.size(); i++) {
safe_dir_name = safe_dir_name.replace(invalid_chars[i], "-");
}
return safe_dir_name;

// Trim trailing periods from the returned value as it's not valid for folder names on Windows.
// This check is still applied on non-Windows platforms so the returned value is consistent across platforms.
return safe_dir_name.rstrip(".");
}

// Path to data, config, cache, etc. OS-specific folders
Expand Down
1 change: 1 addition & 0 deletions doc/classes/ProjectSettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@
<member name="application/config/custom_user_dir_name" type="String" setter="" getter="" default="&quot;&quot;">
This user directory is used for storing persistent data ([code]user://[/code] filesystem). If a custom directory name is defined, this name will be appended to the system-specific user data directory (same parent folder as the Godot configuration folder documented in [method OS.get_user_data_dir]).
The [member application/config/use_custom_user_dir] setting must be enabled for this to take effect.
[b]Note:[/b] If [member application/config/custom_user_dir_name] contains trailing periods, they will be stripped as folder names ending with a period are not allowed on Windows.
</member>
<member name="application/config/description" type="String" setter="" getter="" default="&quot;&quot;">
The project's description, displayed as a tooltip in the Project Manager when hovering the project.
Expand Down

0 comments on commit 6cdd303

Please sign in to comment.