Am Freitag, den 21.12.2007, 13:37 +0100 schrieb Jonas Maebe: > 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.
I know and the writeln was inserted later to be sure the system call fails (=-1). If the line is commented out the results are the same in both cases. Marc _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal