| User-Defined Opcode Database |
|---|
Returns the directory above the current directory
Download UDO FileReturns the directory above the current directory
SUpDir FilDirUp SCurDir
SCurDir - current directory (with or without an ending slash)
SUpDir - directory above the current directory (returned without an ending slash)
opcode FilDirUp, S, S
SCurDir xin
;make sure the input does not end with '/'
ilen strlen SCurDir
ipos strrindex SCurDir, "/"
if ipos == ilen-1 then
Sok strsub SCurDir, 0, ipos
else
Sok strcpy SCurDir
endif
ipos strrindex Sok, "/"
SUpDir strsub Sok, 0, ipos
xout SUpDir
endop
<CsoundSynthesizer>
<CsOptions>
-m0
</CsOptions>
<CsInstruments>
opcode FilDirUp, S, S
;returns the directory above the current directory
SCurDir xin
;make sure the input does not end with '/'
ilen strlen SCurDir
ipos strrindex SCurDir, "/"
if ipos == ilen-1 then
Sok strsub SCurDir, 0, ipos
else
Sok strcpy SCurDir
endif
ipos strrindex Sok, "/"
SUpDir strsub Sok, 0, ipos
xout SUpDir
endop
instr DirUp
SCurDir pwd
puts SCurDir, 1
SDirUp FilDirUp SCurDir
puts SDirUp, 1
endin
</CsInstruments>
<CsScore>
i "DirUp" 0 0
</CsScore>
</CsoundSynthesizer>
returns:
/home/jh/Joachim/Csound/UDO/judo/strings/files
/home/jh/Joachim/Csound/UDO/judo/strings
joachim heintz 2012
| Previous | Home | Next |
| FilDir | FilePlay1 |