News:

Simutrans Chat Room
Where cool people of Simutrans can meet up.

[Patch] FIX search_folder_t::search_path relying on d_type

Started by koroal, December 01, 2022, 10:46:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

koroal

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.

Dwachs

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.
Parsley, sage, rosemary, and maggikraut.

koroal

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:

Dwachs

Parsley, sage, rosemary, and maggikraut.