Page MenuHomeFeedback Tracker

Unexpected behavior of FindFile() on Linux
Feedback, UrgentPublic

Description

Unexpected behavior of FindFile() on Linux with 1.24 server (not tested in experimental branch)

FindFile() when setting the flag FindFileFlags.ALL as well as FindFileFlags.DIRECTORIES finds only files, but does not find directories.
At the same time, it sets an attribute with index 4, which, as I understand it, is outside the scope of enum FileAttr where the last index is 3 with type INVALID

Details

Severity
None
Resolution
Open
Reproducibility
Always
Operating System
Linux x64
Operating System Version
6.1.0-18-amd64 Debian
Category
General
Steps To Reproduce
FindFileHandle handle = FindFile("$mission:/some/*", dir, attr, FindFileFlags.DIRECTORIES);
Print("[DEBUG] FindFileHandle dir: " + dir); // return file, not dir
Print("[DEBUG] FindFileHandle attr: " + attr); // return 4 for file

Event Timeline

WoozyMasta edited Steps To Reproduce. (Show Details)
WoozyMasta updated the task description. (Show Details)Mar 6 2024, 8:35 PM
WoozyMasta updated the task description. (Show Details)

UPD:

also does not find files if something is installed after the glob template, for example:

FindFile("$mission:/some/*.ext", dir, attr, FindFileFlags.DIRECTORIES);
FindFile("$mission:/some/*.ext", dir, attr, FindFileFlags.ALL);

won't find anything

FindFile("$mission:/some/*", dir, attr, FindFileFlags.DIRECTORIES);
FindFile("$mission:/some/*", dir, attr, FindFileFlags.ALL);

will only find files

FindFile("$mission:/some/", dir, attr, FindFileFlags.DIRECTORIES);
FindFile("$mission:/some/", dir, attr, FindFileFlags.DIRECTORIES);
FindFile("$mission:/some", dir, attr, FindFileFlags.ALL);
FindFile("$mission:/some", dir, attr, FindFileFlags.ALL);

won't find anything either

I understand that in linux everything is a file, but this seems to break the inherent logic in many mods, for example EditorLoader or Deliginator

WoozyMasta updated the task description. (Show Details)Mar 6 2024, 9:59 PM
lava76 added a subscriber: lava76.Mar 6 2024, 11:54 PM
Geez changed the task status from New to Assigned.Mar 7 2024, 11:37 AM
Geez changed the task status from Assigned to Confirmed Internally.May 13 2024, 1:11 PM
dedmen added a subscriber: dedmen.Jul 11 2024, 5:46 PM

At the same time, it sets an attribute with index 4, which, as I understand it, is outside the scope of enum FileAttr where the last index is 3 with type INVALID

The FileAttr enum is not a normal enum, its bitflags. Its not documented in script but this is how the enum really looks like

enum FileAttr
{
	DIRECTORY = 1, ///<File is directory
	HIDDEN = 2, ///<File is hidden
	READONLY = 4, ///<File is read-only
	INVALID = -1 ///<Invalid file
};

Thus 4 is a valid value, though incorrect because every file is flagged as readonly due to a bug

The broken pattern matching (when pattern is anything other than just "/*") and the wrong read-only flag should be fixed in 1.26
The DIRECTORIES flag not working is separate, that also does not work on windows. We're handling that in a separate ticket to be solved some other time.

The way I understood FindFileFlags is that it tells FindFile where to find files, not what type of thing (i.e. directory/file) it should find. I'm basing this off the code comments in ensystem.c, so not sure if those are correct w/ regards to intent (it also mentions .pak files which are not a thing in DayZ, probably a leftover from Arma. I haven't checked if FindFileMode.ARCHIVES does attempt to find files in PBOs).

dedmen changed the task status from Confirmed Internally to Feedback.Aug 6 2024, 2:09 PM