Skip to content

Conversation

@Mickeon
Copy link
Member

@Mickeon Mickeon commented Nov 26, 2025

See #107536 (comment)

There are several methods in FileAccess whose parameter's name is file. This is not just inconsistent, but misleading because these methods purely accept a path to a file.
In a class all about accessing any given file's raw data, this distinction matters quite a lot, I feel.

It looks like these methods were added over time, each deriving from the last ( d454e1a 8aa6f29 85d3be8 ). They're quite advanced and certainly targeted towards tech-savvy users, so naming the path file here may come naturally to them. Other FileAccess methods just name the same kind of parameter path, hence my belief that this is an oddity worth fixing.

This PR renames the parameters in all affected methods from file to path. Each corresponding description in the class reference has been updated, as well.

@Mickeon Mickeon added this to the 4.x milestone Nov 26, 2025
@Mickeon Mickeon requested a review from a team as a code owner November 26, 2025 23:50
@Mickeon Mickeon requested a review from a team as a code owner November 26, 2025 23:50
@Mickeon Mickeon requested review from a team and bruvzg and removed request for a team November 26, 2025 23:50
@Mickeon Mickeon force-pushed the rename-FileAccess-file-parameters branch 2 times, most recently from 694fb16 to 54eee7e Compare November 26, 2025 23:55
@Mickeon Mickeon requested a review from a team November 26, 2025 23:55
@Mickeon Mickeon force-pushed the rename-FileAccess-file-parameters branch from 54eee7e to 732ef48 Compare November 27, 2025 00:16

bool FileAccess::exists(const String &p_name) {
if (PackedData::get_singleton() && !PackedData::get_singleton()->is_disabled() && PackedData::get_singleton()->has_path(p_name)) {
bool FileAccess::exists(const String &p_path) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that the exposed method already used path.

@Mickeon Mickeon force-pushed the rename-FileAccess-file-parameters branch from 732ef48 to c2ea770 Compare November 27, 2025 12:02
ClassDB::bind_static_method("FileAccess", D_METHOD("get_extended_attribute", "file", "attribute_name"), &FileAccess::get_extended_attribute);
ClassDB::bind_static_method("FileAccess", D_METHOD("get_extended_attribute_string", "file", "attribute_name"), &FileAccess::get_extended_attribute_string);
ClassDB::bind_static_method("FileAccess", D_METHOD("set_extended_attribute", "file", "attribute_name", "data"), &FileAccess::set_extended_attribute);
ClassDB::bind_static_method("FileAccess", D_METHOD("set_extended_attribute_string", "file", "attribute_name", "_data"), &FileAccess::set_extended_attribute_string);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notice the typo _data here which has been overlooked.


virtual BitField<UnixPermissionFlags> _get_unix_permissions(const String &p_file) = 0;
virtual Error _set_unix_permissions(const String &p_file, BitField<UnixPermissionFlags> p_permissions) = 0;
virtual BitField<UnixPermissionFlags> _get_unix_permissions(const String &p_path) = 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these virtual methods will be confusing when their overrides are different

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I can change them too at the cost of perceived noise in this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd say it's a good reason to avoid it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then I guess I will do nothing about it??

Copy link
Member

@AThousandShips AThousandShips Nov 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO the confusion over "file" vs "path" is not critical enough to create such noise over, especially since IMO most of these cases are obvious in their behavior (Ironically I'd say only the hash methods actually are potentially confusing here)

@AThousandShips
Copy link
Member

Also what's the reason to leave the md5 methods as is that take a path?

@Mickeon
Copy link
Member Author

Mickeon commented Nov 27, 2025

No reason, actually, I just forgot about them. These methods are exposed with the parameter named path already.

@Mickeon Mickeon force-pushed the rename-FileAccess-file-parameters branch from c2ea770 to a2f7d85 Compare November 27, 2025 12:16
@Mickeon
Copy link
Member Author

Mickeon commented Nov 27, 2025

Done and done.

@Mickeon Mickeon force-pushed the rename-FileAccess-file-parameters branch from a2f7d85 to 8395f0c Compare November 27, 2025 12:18
Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I won't block this but I don't think this is a worthwhile change, I don't expect any confusion to arise from these as they were previously and I don't think the noise is worth the hypothetical gain from the uniform naming and nominally clearer naming

If there were actual methods that did take some "file" value I'd say it would be different, but without that I'd say it's not critical. I'd restrict it to just the documentation side if we do anything

Are there any reports or posts on forums etc. indicating that people are running into issues due to the naming?

Edit: Especially since changing these files causes mass rebuild

@Mickeon
Copy link
Member Author

Mickeon commented Nov 27, 2025

If there were actual methods that did take some "file" value I'd say it would be different, but without that I'd say it's not critical.

Parameter name changes are never truly "critical", to be honest. By hoping any of them are, even smaller inconsistencies in the names can never be addressed.
I guess this PR is a huge case, however. I thought I was just going to change a few functions, but it ended up being a

I'd restrict it to just the documentation side if we do anything

I wouldn't mind just changing the exposed names because that would solve my pet peeve anyway. It'd just be inconsistent.

Are there any reports or posts on forums etc. indicating that people are running into issues due to the naming?

No. Good luck finding anything of the sort. These are the minor things that trip up developers just a bit, but not enough to talk about it on any social platform. Inconsistent terminology add to the general sense of unease and the more accessible we make the class reference (#91060, #113214), the more noticeable it is going to be.

@AThousandShips
Copy link
Member

I'd say that the name alone isn't enough to cause confusion, it has to be a case where it's ambiguous if the parameter can be a file in the first place, I can't imagine almost any of these being of that kind, it would require users to assume that you can get this data from the contents of a file, which considering the range of expertise of users is possible but IMO extremely unlikely, and I'd say those users wouldn't be using those methods in the first place, at least not without reading the documentation

So I don't think that these trip developers up at all

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants