use standard dirname using a temp var to get round glibc