Csound Csound-dev Csound-tekno Search About

Re: [Csnd] file exist opcode?

Date2012-02-14 16:35
From"Art Hunkins"
SubjectRe: [Csnd] file exist opcode?
Joachim,

I cannot tell if your suggestion will work on Windows or not.

Csound 5.06, which I happen to need to use, does include the system_i 
opcode. However, on Windows, ires *always* returns a value of 1.

This happens:
1) whether the file exists or not;
2) regardless of what the return value options are (the value[s?] following 
"then").

So, is this a platform-related problem?

If so, is perhaps there another way of formatting the filename that would 
work for Windows?

Art Hunkins

----- Original Message ----- 
From: "joachim heintz" 
To: 
Sent: Tuesday, February 14, 2012 1:52 AM
Subject: Re: [Csnd] file exist opcode?


> hi art -
> this works for linux (ires=0: file noes not exist), and should for osx.
> but on windows?
> perhaps it helps anyways -
> joachim
>
> instr 1
> ires system_i 1, "if [ -f test.csd ] ; then 1 ; fi"
> print ires
> endin
>
> Am 14.02.2012 00:37, schrieb Art Hunkins:
>> Thanks to all for the suggestions.
>>
>> Unfortunately, I cannot count on python always being available.
>>
>> Can anyone suggest a simple solution using the system opcode - one that
>> perhaps parallels "os.path.exists"?
>>
>> Art Hunkins
>>
>>     ----- Original Message -----
>>     *From:* Andres Cabrera 
>>     *To:* csound@lists.bath.ac.uk 
>>     *Sent:* Monday, February 13, 2012 4:42 PM
>>     *Subject:* Re: [Csnd] file exist opcode?
>>
>>     Hi,
>>
>>     Yes, I think using os.path.exists should work on all platforms.
>>
>>     Cheers,
>>     Andrés
>>
>>     On Mon, Feb 13, 2012 at 9:33 PM, joachim heintz >     > wrote:
>>
>>         if the python opcodes can be used, this should be possible.
>>         can they?
>>                joachim
>>
>>         Am 13.02.2012 21:51, schrieb Art Hunkins:
>>         > Do you perhaps have a simple, *cross-platform* call to the
>>         system opcode
>>         > that would return whether or not "soundin.1" was present in
>>         the current
>>         > directory?
>>         >
>>         > (I'm looking for something applicable back to Csound 5.06;
>>         filevalid was
>>         > only introduced in 5.13. Or is there a simple UDO version of
>>         filevalid I
>>         > might appropriate?)
>>         >
>>         > Art Hunkins
>>         >
>>         >     ----- Original Message -----
>>         >     *From:* peiman khosravi >         >
>>         >     *To:* csound@lists.bath.ac.uk
>>          >         >
>>         >     *Sent:* Monday, February 13, 2012 8:36 AM
>>         >     *Subject:* Re: [Csnd] file exist opcode?
>>         >
>>         >     maybe you can use the system opcode for this?
>>         >
>>         >     P
>>         >
>>         >     On 13 February 2012 13:33, Art Hunkins >         
>>         >     >> 
>> wrote:
>>         >
>>         >         I feel sure there must be an opcode that returns a 
>> value
>>         >         indicating whether a specified file exists or not. I
>>         just cannot
>>         >         find it.
>>         >
>>         >         (Otherwise Csound crashes if you ask - via diskin or
>>         soundin -
>>         >         for a file that doesn't exist. I need to avoid this
>>         possibility.)
>>         >
>>         >         Art Hunkins
>>         >
>>         >
>>         >         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"
>>         >
>>         >
>>
>>
>>         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"
>>
>>
>
>
> 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"
> 


Date2012-02-14 17:17
FromAlan Fitch
SubjectRe: [Csnd] file exist opcode?
On 14/02/2012 16:35, Art Hunkins wrote:
> Joachim,
>
> I cannot tell if your suggestion will work on Windows or not.
>
> Csound 5.06, which I happen to need to use, does include the system_i 
> opcode. However, on Windows, ires *always* returns a value of 1.
>
> This happens:
> 1) whether the file exists or not;
> 2) regardless of what the return value options are (the value[s?] 
> following "then").
>
> So, is this a platform-related problem?
>
> If so, is perhaps there another way of formatting the filename that 
> would work for Windows?
>

Hi Art,
   the code in Joachim's example looks like bash script, which won't 
work on Windows.

However this might work...

ires system_i 1, "if not exist test.csd exit 0 else exit 1"

I think the command in the "" needs to be made up of windows batch 
commands. "if exist" tests for a file's existence.

Good luck...

Alan

P.S. Of course this code is Windows specific
> Art Hunkins
>
> ----- Original Message ----- From: "joachim heintz" 
> To: 
> Sent: Tuesday, February 14, 2012 1:52 AM
> Subject: Re: [Csnd] file exist opcode?
>
>
>> hi art -
>> this works for linux (ires=0: file noes not exist), and should for osx.
>> but on windows?
>> perhaps it helps anyways -
>> joachim
>>
>> instr 1
>> ires system_i 1, "if [ -f test.csd ] ; then 1 ; fi"
>> print ires
>> endin
>>
>> Am 14.02.2012 00:37, schrieb Art Hunkins:
>>> Thanks to all for the suggestions.
>>>
>>> Unfortunately, I cannot count on python always being available.
>>>
>>> Can anyone suggest a simple solution using the system opcode - one that
>>> perhaps parallels "os.path.exists"?
>>>
>>> Art Hunkins
>>>
>>>     ----- Original Message -----
>>>     *From:* Andres Cabrera 
>>>     *To:* csound@lists.bath.ac.uk 
>>>     *Sent:* Monday, February 13, 2012 4:42 PM
>>>     *Subject:* Re: [Csnd] file exist opcode?
>>>
>>>     Hi,
>>>
>>>     Yes, I think using os.path.exists should work on all platforms.
>>>
>>>     Cheers,
>>>     Andrés
>>>
>>>     On Mon, Feb 13, 2012 at 9:33 PM, joachim heintz 
>>> >> > wrote:
>>>
>>>         if the python opcodes can be used, this should be possible.
>>>         can they?
>>>                joachim
>>>
>>>         Am 13.02.2012 21:51, schrieb Art Hunkins:
>>> > Do you perhaps have a simple, *cross-platform* call to the
>>>         system opcode
>>> > that would return whether or not "soundin.1" was present in
>>>         the current
>>> > directory?
>>> >
>>> > (I'm looking for something applicable back to Csound 5.06;
>>>         filevalid was
>>> > only introduced in 5.13. Or is there a simple UDO version of
>>>         filevalid I
>>> > might appropriate?)
>>> >
>>> > Art Hunkins
>>> >
>>> >     ----- Original Message -----
>>> >     *From:* peiman khosravi >> >
>>> >     *To:* csound@lists.bath.ac.uk
>>>  >> >
>>> >     *Sent:* Monday, February 13, 2012 8:36 AM
>>> >     *Subject:* Re: [Csnd] file exist opcode?
>>> >
>>> >     maybe you can use the system opcode for this?
>>> >
>>> >     P
>>> >
>>> >     On 13 February 2012 13:33, Art Hunkins >> 
>>> > >> wrote:
>>> >
>>> >         I feel sure there must be an opcode that returns a value
>>> >         indicating whether a specified file exists or not. I
>>>         just cannot
>>> >         find it.
>>> >
>>> >         (Otherwise Csound crashes if you ask - via diskin or
>>>         soundin -
>>> >         for a file that doesn't exist. I need to avoid this
>>>         possibility.)
>>> >
>>> >         Art Hunkins
>>> >
>>> >
>>> >         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"
>>> >
>>> >
>>>
>>>
>>>         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"
>>>
>>>
>>
>>
>> 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"
>>
>
>
>
> 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"
>


-- 
Alan Fitch