ihhub / fheroes2

fheroes2 is a recreation of Heroes of Might and Magic II game engine.
https://ihhub.github.io/fheroes2/
GNU General Public License v2.0
2.69k stars 375 forks source link

*nix case insensitive file access #429

Closed shprotru closed 4 years ago

shprotru commented 4 years ago

Project have an script/demo/demo_linux.sh that will download zip, after extraction data directory named by default as "DATA", but program will attempt to access with naming as "data", which will fail on nix systems, to avoid this need to rename it manually. I think that fheroes2 need case-insensitive file access to be more friendly for new users. In addition different HOMM2 distributives could have different naming and manual renaming on nix is a time wasting.

shprotru commented 4 years ago

I had started to see strange behaviour in function casepath that I have been found in google, then I decided to make a test for function GetCaseInsensitivePath. Have found 2 bugs:

  1. if directory not exists, casepath returns existance flag.
  2. strange comparement with in strcasecmp on my system: if existant folder have localized name returned name in e->d_name will be not the same as I setted in test vector(source file is saved in utf8 encoding).

First issue was resolved(check tests). But second is open, help wanted: need to check on a machine with mac os and understand why casepath fails, may be I do something wrong. I think 2 issue is minor and fheroes2 would work correct on *.nix systems where user-names could be localized, spite on a 2 issue. Issue 2 triggers only if filename contains localized substrings and register is different than searchable element. Example