Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Checking for the existence of a file

1 view
Skip to first unread message

Adam

unread,
Mar 6, 2006, 1:11:01 PM3/6/06
to
Hi,

I've been using OS_File,17 to check for the existence of files, in fact
here's the exact bit of code:

DEF FNcheckfile(file$)
LOCAL spec%, flags%
SYS "OS_File",17,file$ TO spec%;flags%
IF (spec%=0) OR ((flags% AND 1)=1) THEN file$="No Info"
=file$

I have just discovered, however, that this fails if file$ contains an
unknown path, for example: "wibble:no.file.here"

If fails in that it /doesn't/ identify the lack of a file. spec% is set to
some large number and the SWI doesn't generate an error.

Can anyone else repeat this, and if so, what's the solution?

Thanks,
Adam

P.S. RISC OS 4.39

--
Adam Richardson Carpe Diem
http://www.snowstone.org.uk/riscos/

Ste (news)

unread,
Mar 6, 2006, 1:43:22 PM3/6/06
to
In article <db8a7903...@snowstone.org.uk>,

Adam <ne...@snowstone.org.uk> wrote:
> Hi,
>
> I've been using OS_File,17 to check for the existence of files, in fact
> here's the exact bit of code:
>
> DEF FNcheckfile(file$)
> LOCAL spec%, flags%
> SYS "OS_File",17,file$ TO spec%;flags%
> IF (spec%=0) OR ((flags% AND 1)=1) THEN file$="No Info"
> =file$
>
> I have just discovered, however, that this fails if file$ contains an
> unknown path, for example: "wibble:no.file.here"
>
> If fails in that it /doesn't/ identify the lack of a file. spec% is set to
> some large number and the SWI doesn't generate an error.
>
> Can anyone else repeat this, and if so, what's the solution?
>
> P.S. RISC OS 4.39

Works OK here, RISC OS 5.09 (no error, spec%=0). Could be a Select bug -
maybe it's trying to return an error and forgetting to set the V flag. Does
it look like R0 (spec%) is pointing to an error block? E.g.

SYS "XOS_GenerateError", spec%+4 TO err$
PRINT err$

I vaguely recall that select does lots of extra canonicalising that RISC OS
5 doesn't so it may be losing the V flag somewhere in the OS_File 17 handler.

Steve

--
Steve Revill @ Home
Note: All opinions expressed herein are my own.

Ian Hamilton

unread,
Mar 6, 2006, 1:48:22 PM3/6/06
to

> I've been using OS_File,17 to check for the existence of files, in fact
> here's the exact bit of code:

> DEF FNcheckfile(file$)
> LOCAL spec%, flags%
> SYS "OS_File",17,file$ TO spec%;flags%
> IF (spec%=0) OR ((flags% AND 1)=1) THEN file$="No Info"
> =file$

> I have just discovered, however, that this fails if file$ contains an
> unknown path, for example: "wibble:no.file.here"

You need SYS "XOS_File" otherwise flags% isn't set.

Ian

--
Ian Hamilton (RISC PC RO4) http://www.hamiltoni.pwp.blueyonder.co.uk/
(Iyonix RO5) Programs compatible with RISC OS 3/4/5

VinceH

unread,
Mar 6, 2006, 1:51:52 PM3/6/06
to
On 6 Mar 2006, Adam wrote:

> I've been using OS_File,17 to check for the existence of files,
> in fact here's the exact bit of code:

> SYS "OS_File",17,file$ TO spec%;flags%

Try making that SYS "XOS_File",17,etc
^

VinceH

Adam

unread,
Mar 6, 2006, 2:39:03 PM3/6/06
to
In message <4e037ce526I...@AAUG.Net>, Ian Hamilton wrote:
> In article <db8a7903...@snowstone.org.uk>,
> Adam <ne...@snowstone.org.uk> wrote:
> > SYS "OS_File",17,file$ TO spec%;flags%
> You need SYS "XOS_File" otherwise flags% isn't set.

Ooops, that's just a typo. My "real" routine does use XOS.

Adam

Adam

unread,
Mar 6, 2006, 2:43:58 PM3/6/06
to
In message <4e037c80e9s...@revi11.plus.com>, Ste (news) wrote:

> In article <db8a7903...@snowstone.org.uk>,
> Adam <ne...@snowstone.org.uk> wrote:
> > Hi,
> >
> > I've been using OS_File,17 to check for the existence of files, in fact
> > here's the exact bit of code:
> >
> > DEF FNcheckfile(file$)
> > LOCAL spec%, flags%

> > SYS "XOS_File",17,file$ TO spec%;flags%


> > IF (spec%=0) OR ((flags% AND 1)=1) THEN file$="No Info"
> > =file$
> >
> > I have just discovered, however, that this fails if file$ contains an
> > unknown path, for example: "wibble:no.file.here"
> >
> > If fails in that it /doesn't/ identify the lack of a file. spec% is set to
> > some large number and the SWI doesn't generate an error.
> >
> > Can anyone else repeat this, and if so, what's the solution?
> >
> > P.S. RISC OS 4.39
>
> Works OK here, RISC OS 5.09 (no error, spec%=0). Could be a Select bug -
> maybe it's trying to return an error and forgetting to set the V flag. Does
> it look like R0 (spec%) is pointing to an error block? E.g.
>
> SYS "XOS_GenerateError", spec%+4 TO err$
> PRINT err$

"Filing system or path wibble: not present"

So is that a yes? Would checking if spec%>3 be a workable solution?

Thanks,
Adam

Ste (news)

unread,
Mar 6, 2006, 3:47:46 PM3/6/06
to
In article <5a0d8203...@snowstone.org.uk>,

Yes, that looks like an OS bug and yes, your work-around will do the job.
It's a rather heavily-used routine so that's quite a worrying bug to have
kicking around (easy to fix though, I'd imagine).

:)

John Tytgat

unread,
Mar 6, 2006, 4:04:55 PM3/6/06
to
Adam wrote:
> Hi,
>
> I've been using OS_File,17 to check for the existence of files, in fact
> here's the exact bit of code:
>
> DEF FNcheckfile(file$)
> LOCAL spec%, flags%
> SYS "OS_File",17,file$ TO spec%;flags%
> IF (spec%=0) OR ((flags% AND 1)=1) THEN file$="No Info"
> =file$
>
> I have just discovered, however, that this fails if file$ contains an
> unknown path, for example: "wibble:no.file.here"
>
> If fails in that it /doesn't/ identify the lack of a file. spec% is set to
> some large number and the SWI doesn't generate an error.
>
> Can anyone else repeat this, and if so, what's the solution?
>
> Thanks,
> Adam
>
> P.S. RISC OS 4.39

I can't reproduce this with Adjust. Bit 0 of flags% is set and spec%
points to error block "Filing system or path wibble: not present".

John.

Adam

unread,
Mar 8, 2006, 7:32:25 PM3/8/06
to
In message <db8a7903...@snowstone.org.uk>, Adam wrote:

> OS_File,17

> If fails in that it /doesn't/ identify the lack of a file. spec% is set to
> some large number and the SWI doesn't generate an error.

Thanks to some help from John Tytgat I've discovered that the problem is
not, indeed, with the OS, but a module which I've got running here which
sits on the OS_FileV vector.

The module in question is "iSV General RiscOS4 patch" and is present in my
boot sequence (!Boot.Choices.Default.Boot.Tasks.iSV Patch). I didn't put it
there though so I suspect it is part of the Virtual RPC default disc image.

Does anyone know what it's for? I'll mention this on the VA forum too...

Adam

Ste (news)

unread,
Mar 8, 2006, 8:21:54 PM3/8/06
to
In article <2722a404...@snowstone.org.uk>,

Now you mention it, I found this bug and tracked it down then reported it to
Virtual Acorn in July last year. I didn't hear anything much back from them
about it though.

I can't believe I forgot all about it! For those who are interested, here's
what I sent to them...

On 13 Jun, Steve wrote:
> Hi,
>
> I'd like to report a couple of faults/niggles with VirtualRPC SE. The
> first, and probably most serious is a HostFS bug which causes OS_File 17
> (and the like) to report back garbage for some wildcarded pathnames.
>
> For example:
>
> OS_File 17 !Boot.!Run.* will return junk as an object type (R0). In fact,
> it's not junk; it's a pointer to an error block in the HostFS module for
> the "Not found" error but the V flag has not been set. This should return
> an object type of zero.
>
> For an empty directory, the conventional test is OS_File 17 emptydir.*
> which should return an object type of zero. In fact, it returns 2
> (directory).

Peter Naulls

unread,
Mar 9, 2006, 12:38:54 AM3/9/06
to
In message <2722a404...@snowstone.org.uk>
Adam <ne...@snowstone.org.uk> wrote:

> In message <db8a7903...@snowstone.org.uk>, Adam wrote:
>
> > OS_File,17
>
> > If fails in that it /doesn't/ identify the lack of a file. spec% is set to
> > some large number and the SWI doesn't generate an error.
>
> Thanks to some help from John Tytgat I've discovered that the problem is
> not, indeed, with the OS, but a module which I've got running here which
> sits on the OS_FileV vector.
>
> The module in question is "iSV General RiscOS4 patch" and is present in my
> boot sequence (!Boot.Choices.Default.Boot.Tasks.iSV Patch). I didn't put it
> there though so I suspect it is part of the Virtual RPC default disc image.

Some old patch to EasyFontPro, perhaps. That certainly sites on FileV
et al to do its work. I know, having hacked it up to make sure it
worked under RISC OS 5.


--
Peter Naulls - pe...@chocky.org | http://www.chocky.org/
----------------------------------------------------------------------------
RISC OS: Be Informed | http://www.riscos.info/

0 new messages