The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: koroal on December 01, 2022, 10:46:06 AM

Title: [Patch] FIX search_folder_t::search_path relying on d_type
Post by: koroal on December 01, 2022, 10:46:06 AM
After upgrading from the release version of Simutrans to the currently developed version, I had noticed that the pakset selection window has stopped showing and the pakset installation window was shown instead because the game could not find any installed paksets. After investigating a bit, I had discovered that the game uses the d_type field of 'struct dirent' to find subdirectories. Apparently, d_type is not supported on all filesystems, and of those filesystems which have added a support for it, not all permit to enable it without reformatting the whole partition.

In my case, I have one partition with jfs filesystem, which has not been updated for ages, and another partition with xfs, which has added the support for d_type, but, because my partition was formatted before that, the support is disabled and I cannot enable it without recreating the whole filesystem, which I cannot easily do because of the data.

Anyway, I think it would be nice if the game used some more portable way to check for directories. In this patch I use the 'fstatat' function for that.
Title: Re: [Patch] FIX search_folder_t::search_path relying on d_type
Post by: Dwachs on December 02, 2022, 05:38:23 PM
Could you check whether it is possible to do the call to fstatat only if entry->d_type == DT_UNKNOWN? That way the call to fstatat is only done when necessary.
Title: Re: [Patch] FIX search_folder_t::search_path relying on d_type
Post by: koroal on December 02, 2022, 08:06:27 PM
It is certainly possible, but what I think might be even better is to call it not only for d_type == DT_UNKNOWN, but also for d_type == DT_LNK to properly handle symbolic links in all cases. Here is an updated patch version:
Title: Re: [Patch] FIX search_folder_t::search_path relying on d_type
Post by: Dwachs on December 03, 2022, 12:18:09 PM
Thanks! in r10824.