We'd like to do some file operations in a directory two levels above the readPath of a cell's directory.
cv->lib->readPath --> /home/user/project/version/lib
we want to get '/home/user/project'
Using parseString, then chopping off the two last elements, then building the string again, would get us there; is this the best scheme? If so, what's the most efficient way of chopping off the last two elements? Right now we're looking at the list slice question to accomplish it which would be pretty universal but maybe not the most efficient or the least code?
Hmm, looks like the least code would just be:
You could always use simplyFilename() on the result of the strcat if you want to tidy up the path a bit. An alternative would be to use pcre functions to chop off the last part - something like:
lastBit=pcreCompile("/[^/]*/[^/]*$")shortened=pcreReplace(lastBit cv~>lib~>readPath "" 1)
The simplest listy way of doing it would involve using parseString, reverse and cddr and then reversing and buildString again. Not that clean... and not so good if you have long paths or a lot of paths to do it on.