Page MenuHomeFeedback Tracker

FindFile not working on Linux Server
Assigned, UrgentPublic

Description

I recently had someone reporting a problem with my mods, which I have never seen before. After investigating, I found out he was running the DayZ Server on Linux and the problem was, that user json files could not be loaded from a folder. The whole folder would be scanned and all files should be loaded by my mod and the problem was, that FindFile would never return a valid FileHandle even when changing the permissions of the folder to 777 and trying some more possible fixes

Details

Severity
Block
Resolution
Open
Reproducibility
Always
Operating System
Linux x64
Category
General
Steps To Reproduce

Install a DayZ Server on Linux, create a folder in the profiles folder, add some files in there and try to use

string filename;
FileAttr attrs;
FileHandle handle = FindFiles("$profile:TestFolder/*", filename, attrs, FineFileMode.ANY);
if (handle == 0) Error("Could not open folder");
Print("Found: " + filename);
while (FindNextFile(handle, filename, attr))
    Print("Found: " + filename);
CloseFindFile(handle);

Event Timeline

LBmaster created this task.Jun 9 2024, 6:09 PM
Geez changed the task status from New to Assigned.Jun 10 2024, 10:48 AM
Geez assigned this task to dedmen.
Geez added a subscriber: Geez.
dedmen added a comment.EditedJul 28 2024, 10:17 AM

I think this should be fixed in 1.26 too.
I actually never saw this issue during any of my testing so its a bit confusing.

This is the final test script that also QA will use to confirm the fix

void TestFindFiles(string path)
{
	string fileName;
	FileAttr fileAttr;
	Print(path);
	FindFileHandle findFileHandle = FindFile(path, fileName, fileAttr, 0);
	if (findFileHandle) {
		bool isValid = true;
		while (isValid) {
			if (fileName.Length() > 0) {
				Print(fileName);
				Print(fileAttr);
			}
			isValid = FindNextFile(findFileHandle, fileName, fileAttr);
		}
		CloseFindFile( findFileHandle );
	}	
}

In my tests, this script even worked before any of the fixes. And FindNextFile cannot work without a handle (Internally its a pointer to a structure that holds all context)

Maybe only the $profile doesn't work? could that be it?

lava76 added a subscriber: lava76.Jul 29 2024, 10:40 AM

Maybe it's the if (handle == 0) check that makes it fail? Could a valid (non-NULL) FindFileHandle be implicitly cast to a zero int by this comparison, thus making it fail?