Thanks BigChimp.
This is what I came up with, following the link in your reply:
Only Linux - Will need to check if the error also exists on Windows.
for i:=1 to FormConfig.CLB_AddRemote.Items.Count do
begin
// When no NAS bug
if not Formconfig.CB_NasBug.Checked then
begin
if FormConfig.CLB_AddRemote.Checked[i-1] then
begin
CheckThisDir:= FormConfig.CLB_AddRemote.Items[i-1];
FormAbout.Memo1.Lines.Add('Checking Folder '+CheckThisDir+' for music');
FilesFound:=FindAllFiles(CheckThisDir, '*.mp3;*.flac;*.ogg', True);
Form1.ListAll.Items.AddStrings(FilesFound);
end;
end
else
// When NAS BUG
begin
CheckThisDir:= FormConfig.CLB_AddRemote.Items[i-1];
FormAbout.Memo1.Lines.Add('Checking Folder '+CheckThisDir+' for music');
MemStream := TMemoryStream.Create;
BytesRead := 0;
OurProcess := TProcess.Create(nil);
OurProcess.CommandLine := 'find '+CheckThisDir+' -iname *.ogg -o -iname *.flac -o -iname *.mp3';
OurProcess.Options := [poUsePipes];
OurProcess.Execute;
while OurProcess.Running do
begin
MemStream.SetSize(BytesRead + READ_BYTES);
NumBytes := OurProcess.Output.Read((MemStream.Memory + BytesRead)^, READ_BYTES);
if NumBytes > 0 then Inc(BytesRead, NumBytes)
else Sleep(100);
end;
repeat
MemStream.SetSize(BytesRead + READ_BYTES);
NumBytes := OurProcess.Output.Read((MemStream.Memory + BytesRead)^, READ_BYTES);
if NumBytes > 0 then Inc(BytesRead, NumBytes);
until NumBytes <= 0;
if BytesRead > 0 then WriteLn;
MemStream.SetSize(BytesRead);
FilesFound.LoadFromStream(Memstream);
Form1.ListAll.Items.AddStrings(FilesFound);
OurProcess.Free;
MemStream.Free;
end;
end;