On 21 Dec 2007, at 06:37, Marc Santhoff wrote:

when I try to use getlastoserror something "funny" happens.

We're dealing with:

$ ll /home/marc/program/Test_C/unreadable/
ls: : Permission denied

The source:

  tmp := aFile^ + '/' + dirrec.Name;
  writeln('file: '+ tmp );
  n := fpaccess(tmp , R_OK);
  writeln(n);
  n := getlastoserror;
  writeln(n);

The output:

file: /home/marc/program/Test_C/unreadable/
-1
-65523

Regardless of what the real problem is, the above code is wrong: writeln (obviously) also makes use of OS functions to write things out to the screen, and if one of those (temporarily) fails for some reason (e.g., ESysEINTR) then your call to getlastoserror will return the result of that failure. Just like with ioresult, you always have to store the result of getlastoserror immediately in a local variable after the operation you want to check.


Jonas
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to