Archive 17/01/2023.

Assorted Filesystem Related Questions

SirNate0

This is a thread for me to ask assorted questions about Filesystem related functions (such as GetInternalPath, AddTrailingSlash, etc.) and their usages while working on adding a Path class to Urho instead of just String and a handful of functions.

To start things off, why is GetInternalPath used here and not ResourceCache::SanitateResourceName?

void AnimationController::FindAnimation(const String& name, unsigned& index, AnimationState*& state) const
{
    StringHash nameHash(GetInternalPath(name));
...
Modanung

I think this may mainly be an optimization; SanitateResourceName is more complex and FindAnimation is called by almost all of AnimationController's member functions.

SirNate0

Seems plausible. If that’s the case, though, I think we should probably not call GetInternalPath and just require the user to pass a proper (internal, trimmed) string. I don’t plan on doing either option, that’s just my thoughts on the matter.

Modanung

Another option would be to add #ifdef _WIN32 either within GetInternalPath or anywhere the function is used. I expect this would not cause problems since GetNativePath also assumes no modification to the string are required when operating outside of bat country (aka Windows).