added options to set mode (used by mkdir and chmod)  for cache directory and files