Have a program that backs up selected directories.
The issue is that I have a file that starts with a single quote '48 (its an ebook so dont really want to rename it to get around this problem)
When using findfirst it usually gets . and .. first, but in this case it gets '48
So:
Result := FindFirst(SourcePrefix+'\'+RootDir + '\*.*', FaAnyFile, sr);
if Result <> 0 then
begin
SysUtils.findclose(sr);
ShowMessage('CopyUpdate: ' + SysUtils.SysErrorMessage(SysUtils.GetLastOSError) + ' ' + RootDir);
Halt;
exit;
end;
findnext(sr); {skip . and ..}
while findnext(sr) = 0 do...
ends up having .. and recursively goes to infinity.
Where:
if FindFirst(RootDir + '*.*', FaAnyFile, sr) = 0 then
begin
repeat
if sr.Name = '.' then findnext(sr);
if sr.Name = '..' then findnext(sr);
...
Works fine for '48 but fails where there is an empty directory somewhere in the tree (recursively off to infinity again).
Is there a way to account for both?
Thanks Derek