added chmod() to createPath()