Re: [fpc-pascal] FPC docs about FindFirst

2019-09-23 Thread Anthony Walter
Related,

It would seem on Linux that FindFirst, FindNext or TSearchRec that none of
them can properly detect a symbolic link. For example, if you wanted
enumerate files and folder, and there exists a symbolic link inside one
folder to some parent of said folder, it's not possible to detect leading
to endless recursion. faSymLink currently isn't picked up. I have to use
code like this:

uses
  BaseUnix;

function IsSymLink(const Path: string): Boolean;
var
  Stat: TStat;
begin
  fpLstat(PChar(Path), Stat);
  Result := fpS_ISLNK(Stat.st_mode);
end;

Which slows down the search a bit.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC docs about FindFirst

2019-09-23 Thread Ralf Quint

On 9/23/2019 3:53 PM, James Richters wrote:

I have ported Turbo Pascal code but then use Sysutils instead of DOS,  my 
intention was to convert it to a windows console application that used windows 
features, and I had no interest in maintaining Turbo Pascal backward 
compatibility, and the use of findfirst, findnext, etc, was part of the code 
that never changed.  I actually was not aware that there even was a command 
called findclose, and I never did it in Turbo Pascal.. it IS in there now, and 
I believe it was a discussion on this list that prompted me to add it.   
Anyway, just wanted to say, there are reasons to want to port Turbo Pascal code 
and then switch over to systutils, so having documentation that includes the 
differences between the versions would be helpful.


Turbo Pascal (for DOS) didn't have a FindClose function, as 
"officially", this would not be necessary on DOS. On all other OS, 
including Windows, for many, many years (I first stumbled about missing 
"FindClose" call in OS/2 some time in the early '90s) and got used to 
*alway**s* terminate a file search with it, even if it is in the case of 
DOS just a dummy routine that just returns without doing nothing. Saves 
a lot of headaches trying to find the source of apparent memory leaks in 
larger applications that do a lot of of file searches...


Ralf



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal


Re: [fpc-pascal] FPC docs about FindFirst

2019-09-23 Thread James Richters
I have ported Turbo Pascal code but then use Sysutils instead of DOS,  my 
intention was to convert it to a windows console application that used windows 
features, and I had no interest in maintaining Turbo Pascal backward 
compatibility, and the use of findfirst, findnext, etc, was part of the code 
that never changed.  I actually was not aware that there even was a command 
called findclose, and I never did it in Turbo Pascal.. it IS in there now, and 
I believe it was a discussion on this list that prompted me to add it.   
Anyway, just wanted to say, there are reasons to want to port Turbo Pascal code 
and then switch over to systutils, so having documentation that includes the 
differences between the versions would be helpful.

James

>As mentioned by Sven, there's probably no reason for any adapting it - people 
>porting Turbo Pascal code use Dos.Find* rather than the sysutils version and 
>since Dos.FindFirst >doesn't return a handle directly (it's hidden within the 
>SearchRec record), calling Dos.FindClose always is the safest bet.
___
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal