optional dirname can be speficied