I am currently stuck with this bit of code that only gives me the very first occurrence of a specific file in the top most folder of a given directory that I am trying to find. I want to modify this to list/return all occurrences of the file.
{ Credits to (I believe) TLama for some/most of this excerpt of code. }
{ Looks for specific file }
var
filelocation: string;
{ ^ Global Variable }
function FindFile(RootPath: string; FileName: string): string;
var
FindRec: TFindRec;
FilePath: string;
begin
Log(Format('', [RootPath, FileName]));
if FindFirst(RootPath + '\*', FindRec) then
begin
try
repeat
if (FindRec.Name <> '.') and (FindRec.Name <> '..') then
begin
FilePath := RootPath + '\' + FindRec.Name;
if FindRec.Attributes and FILE_ATTRIBUTE_DIRECTORY <> 0 then
begin
Log(FilePath);
Result := FindFile(FilePath, FileName);
if Result <> '' then Exit;
end
else
if CompareText(FindRec.Name, FileName) = 0 then
begin
{ list each \userdata\(numbers here) here that include 240.json within them }
Log(Format('User' + {user} + ' owns (Game Here) on Steam.', [FilePath]));
Result := FilePath;
filelocation := FilePath
end;
end;
until not FindNext(FindRec);
finally
FindClose(FindRec);
end;
end
else
begin
Log(Format('Failed to list %s', [RootPath]));
MsgBox('You do not own (Game Here). Please purchase and install it from Steam.',
mbError, MB_OK);
Exit;
end;
end;