| Tito,
Thanks for all this good work.
These suggestions have become way too complex for my simple situation.
The current filevalid opcode, I presume, is also as complicated as this. Is
this so?
I gather that the problem here is basically dealing with varied operating
systems?
Art Hunkins
----- Original Message -----
From: "Tito Latini"
To:
Sent: Wednesday, February 15, 2012 5:58 AM
Subject: Re: [Csnd] file exist opcode?
> Here is a portable (I think) `filevalid_*' that uses
> the `system_i' opcode (tested with 5.07)
>
>
>
>
> gios_check = 0
>
> ;; ires filevalid_S filename
> opcode filevalid_S, i, S
> Sfile xin
> if (gios_check == 1) igoto cont
> ires system_i 1, "exit nonzero"
> if (ires != 0) then
> ;; unix (like)
> gSfmt = "test ! -f '%s'"
> else
> ;; windows/dos
> gSfmt = "if exist %s exit 1"
> endif
> gios_check = 1
> cont:
> Scmd sprintf gSfmt, Sfile
> ires system_i 1, Scmd
> xout (ires != 0 ? 1 : 0)
> endop
>
> ;; ires filevalid_i ifilcod
> opcode filevalid_i, i, i
> ifilcod xin
> Sfile sprintf "soundin.%d", ifilcod
> ires filevalid_S Sfile
> xout ires
> endop
>
> instr 1 ; test
> ires filevalid_S "somefile.wav"
> print ires
> ires filevalid_i 1 ; check soundin.1
> print ires
> endin
>
>
>
> i1 0 1
>
>
>
> tito
>
>
> Send bugs reports to the Sourceforge bug tracker
> https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe
> csound"
>
|