[fpc-pascal] findfirst and findnext on non accessible files

Tomas Hajny XHajT03 at mbox.vol.cz
Wed Jun 28 11:01:27 CEST 2006


Marc Santhoff wrote:


Hi,

> trying to use FindFirst and FindNext on files I cannot detect the
> difference between a failed call because of no matching file and a
> failure when the file or dir is not listable by the user lacking
> permissions.
>
> If I'd use fpstat and friends myself this would mean doing anything
> doubly and having to write some code for each os in question.
>
> Is there any function or procedure that could help me here? Or should
> the implementation of FindFirst/Next be adapted to respect users
> credits?

Which platform are you talking about, which FindFirst/FindNext
(Dos/SysUtils) and what is the behaviour expected from you? E.g. with:
---
uses
 Dos;
var
 SR: SearchRec;
begin
 FindFirst ('M:\IT\AuditPro', AnyFile, SR);
 WriteLn (DosError);
 FindClose (SR);
 FindFirst ('M:\IT\AuditPro\.', AnyFile, SR);
 WriteLn (DosError);
 FindClose (SR);
 FindFirst ('M:\IT\AuditPro\X', AnyFile, SR);
 WriteLn (DosError);
 FindClose (SR);
end.
===
running under Win32, where I don't have access to "M:\IT\AuditPro"
directory, but I have access to "M:\IT" (i.e. I can see the AuditPro
directory itself), I get:

0
0
5

(where 5 corresponds to Access Denied).

Note that I don't know whether "M:\IT\AuditPro\X" exists or not (but that
is OK, IMHO).

Tomas




More information about the fpc-pascal mailing list