1. Existence

--part1_3f.90c8408.29d69088_boundary

Hello.

       A quick question:

             How do I check the existence of a file?

--part1_3f.90c8408.29d69088_boundary

<HTML><FONT FACE=arial,helvetica><FONT  SIZE=2>Hello.
<BR>
<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A quick question:
<BR>

--part1_3f.90c8408.29d69088_boundary--

new topic     » topic index » view message » categorize

2. Re: Existence

On 29 Mar 2002, at 22:52, Robsz2 at aol.com wrote:

> 
> --part1_3f.90c8408.29d69088_boundary
> Content-Type: text/html; charset="US-ASCII"
> Content-Transfer-Encoding: 7bit
> 
> <HTML>
> <PRE>============ The Euphoria Mailing List ============ 
> </PRE>
> 
> <FONT FACE=arial,helvetica><FONT  SIZE=2>Hello.
> <BR>
> <BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A quick question:
> <BR>
> <BR>
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;How
> do I check the existence of a file?</FONT>

Either try to open it with open(), or read the directory with dir() to see if it
is
there. If it isn't there, open() will give an error. If it isn't there, dir()
won't list it.

Kat

new topic     » goto parent     » topic index » view message » categorize

3. Re: Existence

Try this function

global function filelen(sequence st)
object hasildir
    hasildir = dir(st)
    if atom(hasildir) or length(hasildir) = 0 then
        return -1
    end if
    return hasildir[1][3]
end function

st is name of the file.

return -1 if file not exist
return 0 if file 0 bytes or opened for writing
return else = file size


R> Hello.

R>        A quick question:

R>              How do I check the existence of a file?

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu