[fpc-pascal] RE: findfirst and findnext on non accessible files
Marc Santhoff
M.Santhoff at t-online.de
Thu Jun 29 16:16:09 CEST 2006
Am Donnerstag, den 29.06.2006, 09:12 +0200 schrieb Marco van de Voort:
> > On 28 Jun 06, at 23:41, Marc Santhoff wrote:
> > > Am Mittwoch, den 28.06.2006, 12:17 -0500 schrieb Jeff Pohlmeyer:
> > .
> > .
> > > What I don't understand is why the var "errno" is not set or it's value
> > > is destroyed before Findfirst/-Next return. Does this value has to be
> > > set explicitely by using fpseterrno()? It returns always -1 in case of
> > > permission denied.
> >
> > My opinion is that SysUtils.FindFirst should
> > return 5 in case of an error; "errno" is not
> > portable, whereas SysUtils is supposed to support
> > portable code.
I think so, too. Since nowadays even Windows (2000/XP) has a concept of
user permissions, this would be at least nice to have.
> (that is not really the problem, OS errorcodes can be hauled with
> getlastoserror, which is errno on *nix)
I see, I did not know "getlastoserror". But it calls fpGetErrNo in term
and this value is not usable:
program unixerr;
uses
sysutils;
var
SR: TSearchRec;
begin
FindFirst (ParamStr ( 1 ), faAnyFile, SR);
writeln(getlastoserror);
FindClose (SR);
end.
$ ./unixerr /usr/X11R6/include/
2
$ ./unixerr /usr/X11R6/include/nvu-1.0/
-1
$ ll /usr/X11R6/include/nvu-1.0/
ls: : Permission denied
$ ll -F /usr/X11R6/include/ | grep / | grep nvu
drwx------ 104 root wheel 8192 6 Okt 2005 nvu-1.0/
That brings us back to the start. My only question right now:
How can i detect if sysutils.FindFirst() or FindNext() fails lacking
permissions?
TIA,
Marc
More information about the fpc-pascal
mailing list